Like Tree1Likes
  • 1 Post By grumpy

goto in 64 bit Windows C

This is a discussion on goto in 64 bit Windows C within the C Programming forums, part of the General Programming Boards category; I have a question about compiling C for 64 bits on Windows. I am a long time experienced programmer, but ...

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    3

    goto in 64 bit Windows C

    I have a question about compiling C for 64 bits on Windows.

    I am a long time experienced programmer, but relatively new to C (7 years). I rarely use Windows for anything. A year ago I ported a 32 bit C application to 64 bits in Linux and Mac, gcc. I would like to use the same code in Windows, but hit a problem. (It's about 100,000 lines.)

    This application was originally in Pascal. It has a few very important long distance jumps through the code with goto. This is very natural in Pascal, less so in C. In C, this was implemented with setjmp and longjmp.

    There was never any problem in 32 bits with Mac or Linux, or in 64 bits with Mac or Linux. But the 64 bit Windows C compiler won't buy it! (I haven't tried 32 bit Windows).

    Has anyone ever hit this problem? Thanks for any advice.



  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,300
    Please post the error you are getting and the line of code that causes it, plus any other relevant lines of code.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    3
    That's going to take several days. i was hoping someone else had encountered this problem.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    In lieu of a huge bit of the program, can you create a very small example that shows the problem?

    100,000 lines? You caught a whale!

  5. #5
    Registered User
    Join Date
    Oct 2011
    Posts
    3
    > 100,000 lines? You caught a whale! http://im.cprogramming.com/images/smilies/tongue.png

    I wrote it.

    I solved my problem, at least for now. I've used Cygwin to compile the application, named Fermat, for 32 bits in Windows. It works great. The mingw compiler was the problem. It will not accept sigjmp. Cygwin is great.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    What is the difference between longjmp and sigjmp?

    I was looking at my Pelles C compiler, which doesn't have sigjmp, but has an include header for doing what I believe you wanted:

    From Pelles C help file:

    #include the standard file <setjmp.h> to perform global jumps. That is, to go from one function to another without the normal calling and return conventions.

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    6,259
    100,000 lines is negligible.

    If you wrote the program, you presumably have some concept in mind of what the code is doing with setjmp() and longjmp() (which, incidentally, are something completely different from goto). That means you should be able to write a smaller program that exhibits the problem.

    The most common problem folks encounter with setjmp()/longjmp() are due to the function which called setjmp() returning which invalidates the jmp_buf, and some other function attempts to use longjmp() with that (now invalidated) jmp_buf. A common symptom is code that works with some compilers but not with others: C99 compilers are more likely to detect that sort of problem at compile time than older compilers.

    However, make no mistake. The problem is with your code, not with any of your compilers.
    Salem likes this.
    Right 98% of the time, and don't care about the other 3%.

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    ^^^ I clearly write up negligible code!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. goto
    By R.Stiltskin in forum C++ Programming
    Replies: 33
    Last Post: 12-30-2009, 06:23 PM
  2. Why is goto bad?
    By DarkAlex in forum C++ Programming
    Replies: 28
    Last Post: 12-02-2007, 10:24 AM
  3. Why is goto so bad?
    By Munkey01 in forum C++ Programming
    Replies: 14
    Last Post: 01-02-2003, 06:11 PM
  4. Goto
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 11-22-2001, 07:41 AM
  5. Help with 'goto'
    By BubbleMan in forum Windows Programming
    Replies: 1
    Last Post: 09-22-2001, 10:54 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21