porting to Windows, 16/32-bit?

This is a discussion on porting to Windows, 16/32-bit? within the C Programming forums, part of the General Programming Boards category; Hi, I am a C noob, just starting to learn. I wrote a couple simple programs in my Debian Linux ...

  1. #1
    Registered User cDev's Avatar
    Join Date
    Jun 2006
    Posts
    26

    porting to Windows, 16/32-bit?

    Hi, I am a C noob, just starting to learn. I wrote a couple simple programs in my Debian Linux environment and I'm trying to port them to Windows. I created a 16-bit .exe with gcc, but Windows XP apparently won't run any executables lower than 32-bit! Any suggestions? Is there some kind of program that can convert 16 to 32-bit? Do I have to rewrite/recompile my code in a Wintel environment using a Wintel compiler that has the ability to compile to 32-bit executables? Thanks for any suggestions...

    EDIT:
    Ok, I'm an idiot, forgot C is platform-specific, will recompile in windows with some sort of free GNU compiler...(I'm coming from more of a Java background although I am still a bit of a Java noob as well.)
    However I'm still curious as to what the differences in code might be? For example, do you have to link to different libraries in Windows?
    Last edited by cDev; 06-05-2006 at 11:14 AM.

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    I'm not sure I understand your queston but AFAIK, the only MS OS to not support 16bit apps is Windows XP Pro x64 edition. MS claims that the security issues are overwhelming if they support 16 bit apps on this OS.

    All other OS's up to and including XP PRO support DOS (Console) apps thru their own Virtual DOS Machine (VDM). Whereas Win16 GUI apps share a common VDM

    Win16 apps can also call 32bit API's thru a process called thunking

  3. #3
    Registered User cDev's Avatar
    Join Date
    Jun 2006
    Posts
    26
    Quote Originally Posted by BobS0327
    All other OS's up to and including XP PRO support DOS (Console) apps thru their own Virtual DOS Machine (VDM). Whereas Win16 GUI apps share a common VDM
    Thanks for your reply, that is interesting and good to know!
    I am slightly more familiar with the Linux environment than Windows...but I wanted to make sure there wasn't a problem with my source...does C source sometimes vary from platform to platform?

  4. #4
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    does C source sometimes vary from platform to platform?
    From a GUI perspective, the code changes from platform to platform, from Windows to Linux, to Mac, PDA etc. The amount of change is dependent upon what you are developing and the approach you use. Even a cross platform product such as wxWidgets does require some modification for portability.

    There are standards such as ANSI for non GUI development. Unfortunately, almost all of my work is GUI in nature. So, I'm really not qualified to expound on the standards. That's best left to the other more experienced standards folks.

  5. #5
    Registered User cDev's Avatar
    Join Date
    Jun 2006
    Posts
    26
    Quote Originally Posted by BobS0327
    There are standards such as ANSI for non GUI development.
    Actually, my code is based on the book I am learning from; The C Programming Language (second edition) which supposedly is ANSI compliant. In any case, I think the best thing would be for me to take my source and try compiling and running it using a wintel compiler. Thanks again for your helpful info

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    If the code you're trying to compile doesn't use the X-windowing system, you should be able to compile it under Windows with little or no change with gcc or Dev-C++ or cygwin.

    do you have to link to different libraries in Windows?
    For the standard libraries, no. -lm links the math library on most gcc systems.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    Registered User cDev's Avatar
    Join Date
    Jun 2006
    Posts
    26
    Quote Originally Posted by dwks
    If the code you're trying to compile doesn't use the X-windowing system, you should be able to compile it under Windows with little or no change with gcc or Dev-C++ or cygwin.
    Thanks for the info...I downloaded Dev-C++ and so far I like it...however, when I double click the exe my program comes up for a second then gets killed. I have to navigate to it in DOS to get it to come up correctly.
    Is there any way (add a line of code maybe) to make the exe stop long enough for the user to be able to read the program's output? Or any other way to modify the exe?

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  9. #9
    Registered User cDev's Avatar
    Join Date
    Jun 2006
    Posts
    26
    dwks --
    Cool, thanks

    This worked as kind of a quick and dirty fix:
    Code:
    #include <stdio.h> 
    
    int main(void)
    {
      int ch;
      printf ("Press [Enter] to continue");
      while ((ch = getchar()) != '\n' && ch != EOF);
      return(0);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  2. Porting Beej to Windows,
    By m.mixon in forum Networking/Device Communication
    Replies: 1
    Last Post: 06-24-2006, 09:53 PM
  3. bit patterns of negtive numbers?
    By chunlee in forum C Programming
    Replies: 4
    Last Post: 11-08-2004, 08:20 AM
  4. Menu Item Caption - /a for right aligned Accelerator?
    By JasonD in forum Windows Programming
    Replies: 6
    Last Post: 06-25-2003, 12:14 PM

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