Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2008

Tip: Looking for answers? Try searching our database.

about goto

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Abubakar - 06 Mar 2008 07:30 GMT
Hi,
I got this code from some site:

#include <stdio.h>
int
main() {
       int n = -1;
x0:
       printf("%d\n" , ++n);
       goto *(&&x0 + n/1000 * (&&x1 - &&x0));
x1:
       return 0;
}

it doesnt compile successfully. Apparently the goto statement need a
hardcoded *label* for a correct compilation. The above code maybe written in
gcc i think. Am i right to say that this code cannot compile in vc?

regards,
..ab
Ben Voigt [C++ MVP] - 06 Mar 2008 20:19 GMT
> Hi,
> I got this code from some site:
[quoted text clipped - 13 lines]
> hardcoded *label* for a correct compilation. The above code maybe written
> in gcc i think. Am i right to say that this code cannot compile in vc?

Neither C nor C++ allow computed goto.  Computed goto may have some
performance advantages over naive control structures, but the optimizing
compiler should generate code at least as fast as computed goto.

> regards,
> ..ab
Ben Voigt [C++ MVP] - 06 Mar 2008 20:41 GMT
>> Hi,
>> I got this code from some site:
[quoted text clipped - 17 lines]
> performance advantages over naive control structures, but the optimizing
> compiler should generate code at least as fast as computed goto.

Also note that an array of function pointers is possible in C (or C++), and
provides a computed gosub.

>> regards,
>> ..ab

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.