I just found out that a label at the end of a c/c++ function must have
an executable statement after it.
int aMethod ()
{
int aFakeVar = 0;
goto aLabel;
aLabel:
aFakeVar++;
}
Is there any way to get around the requirement of the executable
statement after the label ?
Thanks,
Lynn
On Monday, August 29, 2022 at 6:35:54 PM UTC-7, Lynn McGuire wrote:
I just found out that a label at the end of a c/c++ function must have
an executable statement after it.
int aMethod ()
{
int aFakeVar = 0;
goto aLabel;
aLabel:
aFakeVar++;
}
Is there any way to get around the requirement of the executable
statement after the label ?
Thanks,
Lynn
Use an empty statement, i.e. "label:;".
Is there any way to get around the requirement of the executable
statement after the label ?
Use an empty statement, i.e. "label:;".
I just found out that a label at the end of a c/c++ function must have
an executable statement after it.
int aMethod ()
{
int aFakeVar = 0;
goto aLabel;
aLabel:
aFakeVar++;
}
Is there any way to get around the requirement of the executable
statement after the label ?
I just found out that a label at the end of a c/c++ function must have
an executable statement after it.
int aMethod ()
{
int aFakeVar = 0;
goto aLabel;
aLabel:
aFakeVar++;
}
Is there any way to get around the requirement of the executable
statement after the label ?
P.S. Why is this also posted to a Fortran group?
Fortran has no problem with labels at the end of subroutines
or functions. This is legal:
subroutine a
goto 100
100 end subroutine a
although good style would seem to advise
subroutine a
goto 100
100 continue
end subroutine a
(The "continue" statement is a do-nothing placeholder).
On Tuesday, August 30, 2022 at 7:44:23 AM UTC-7, Kenny McCormack wrote:
(snip)
P.S. Why is this also posted to a Fortran group?
I believe it was accidental, but since you could call it
with the C interoperability feature, it might be applicable.
P.S. Why is this also posted to a Fortran group?
Because I typed comp.lang.c into Thunderbird and
Thunderbird graciously also put comp.lang.fortran in there
for me which I did not notice.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 159 |
Nodes: | 16 (0 / 16) |
Uptime: | 98:39:55 |
Calls: | 3,209 |
Files: | 10,563 |
Messages: | 3,009,783 |