Hoi RGJ,
Geef het stukje code eens en de foutmelding(en) ?
Even terugkoppeling van voorbeeld die ik aan Simon heb gestuurd.
Simon Tatham [anakin@pobox.com] beantwoording (zo 27-2-2011 10:46)van mijn vraag aan hem:
“jan marco alkema” jm.alkema@home.nl wrote:
I want to compile the fzsftp source files from “Compile as C Code
(/TC)” to “Compile as C++ Code (/TP)”. Compile as C Code works, but
Compile as C++ gives the next type of errors: “error C2360:
initialization of ‘e’ is skipped by ‘case’ label
c:\dev\fzsftp\src\cr_remove.c(4648) : see declaration of ‘e’”.
It’s true that there is a way into that switch statement which skips the code that initialises e, but it shouldn’t in principle be harmful, because e is not used by any code reachable from that case label - it’s only ever used by code that enters the block containing e from the very top.
I don’t know why your compiler is giving an error for that code in
C++ mode only. Perhaps C++ makes that construction illegal, whereas
in C it’s merely legal but dangerous so it’s up to the programmer to know what they’re doing? I don’t have a copy of the C++ standard to hand today (and it’s unreadable in any case), so I can’t easily check.
You could probably get rid of the error by putting an extra pair of braces around the initialisation of e and all its uses, but not extending it as far as the crWaitUntilV. I’d do something like this:
if (ssh->mainchan && !ssh->ncmode && *ssh->cfg.environmt) {
{
char *e = ssh->cfg.environmt;
char *var, *varend, *val;
s->num_env = 0;
while (*e) {
var = e;
while (*e && *e != '\t') e++;
varend = e;
if (*e == '\t') e++;
val = e;
while (*e) e++;
e++;
s->pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
ssh2_pkt_adduint32(s->pktout, ssh->mainchan->remoteid);
ssh2_pkt_addstring(s->pktout, "env");
ssh2_pkt_addbool(s->pktout, 1); /* want reply */
ssh2_pkt_addstring_start(s->pktout);
ssh2_pkt_addstring_data(s->pktout, var, varend-var);
ssh2_pkt_addstring(s->pktout, val);
ssh2_pkt_send(ssh, s->pktout);
s->num_env++;
}
logeventf(ssh, "Sent %d environment variables", s->num_env);
}
s->env_ok = 0;
s->env_left = s->num_env;