Difference between Windows and Linux GCC compiler

Discussion in 'C Programming' started by lancer6238@yahoo.com, Jul 31, 2009.

  1. Guest

    Hi all,

    I'm interested to know what is the difference in programming using MS
    Visual C++ on Windows and using the GCC compiler on Linux, i.e. what
    are some of the things I can do on Visual C++ that won't compile/run
    on Linux, and vice versa.

    For example, I know that Windows uses the LLP64 model, while Linux
    uses the LP64 model, so I can't use the long long data type when
    programming on Linux. Also, the windows.h file is only available in
    Windows, and can't be used on Linux. I've also read that there is also
    some differences in network programming, since winsock, and especially
    the underlying ip headers are much different in Windows than Unix/
    Linux gcc. Is this true?

    Thank you.
    , Jul 31, 2009
    #1
    1. Advertising

  2. Tim Prince Guest

    wrote:

    >
    > I'm interested to know what is the difference in programming using MS
    > Visual C++ on Windows and using the GCC compiler on Linux, i.e. what
    > are some of the things I can do on Visual C++ that won't compile/run
    > on Linux, and vice versa.
    >
    > For example, I know that Windows uses the LLP64 model, while Linux
    > uses the LP64 model, so I can't use the long long data type when
    > programming on Linux. Also, the windows.h file is only available in
    > Windows, and can't be used on Linux. I've also read that there is also
    > some differences in network programming, since winsock, and especially
    > the underlying ip headers are much different in Windows than Unix/
    > Linux gcc.
    >


    As you're posting on a group about standard C, much of what you mention
    is off topic. Some of it might be topical on the gcc-help mailing list
    (subscribe at http://gcc.gnu.org).
    MSC has little C99 support, while gcc has a fair amount, including,
    contrary to your assertion, long long int.
    The LP64 model on 64-bit linux implies 64-bit long int and pointer data
    types. On 32-bit linux, those are 32-bit data types, according to ILP32
    model. <stdint.h> is available in gcc.
    Tim Prince, Jul 31, 2009
    #2
    1. Advertising

  3. Flash Gordon Guest

    wrote:
    > Hi all,
    >
    > I'm interested to know what is the difference in programming using MS
    > Visual C++ on Windows and using the GCC compiler on Linux, i.e. what
    > are some of the things I can do on Visual C++ that won't compile/run
    > on Linux, and vice versa.


    The bits you can definitely use are those defined by the C90 standard,
    since when properly prompted both compiler fully conform (modulo bug).

    > For example, I know that Windows uses the LLP64 model, while Linux
    > uses the LP64 model, so I can't use the long long data type when
    > programming on Linux.


    As someone else pointed out you can use long long on Linux. If you need
    specific sizes the normal way is #define appropriately named types (C99
    adds a header which does this for you, but MS does not do C99).

    > Also, the windows.h file is only available in
    > Windows, and can't be used on Linux. I've also read that there is also
    > some differences in network programming, since winsock, and especially
    > the underlying ip headers are much different in Windows than Unix/
    > Linux gcc. Is this true?


    All of those bits are outside the C standard and there are certainly
    some differences in networking, GUI and the like.
    --
    Flash Gordon
    Flash Gordon, Jul 31, 2009
    #3
  4. Frank Guest

    On Jul 30, 9:44 pm, Tim Prince <> wrote:
    > wrote:
    >
    > > I'm interested to know what is the difference in programming using MS
    > > Visual C++ on Windows and using the GCC compiler on Linux, i.e. what
    > > are some of the things I can do on Visual C++ that won't compile/run
    > > on Linux, and vice versa.

    >
    > > For example, I know that Windows uses the LLP64 model, while Linux
    > > uses the LP64 model, so I can't use the long long data type when
    > > programming on Linux. Also, the windows.h file is only available in
    > > Windows, and can't be used on Linux. I've also read that there is also
    > > some differences in network programming, since winsock, and especially
    > > the underlying ip headers are much different in Windows than Unix/
    > > Linux gcc.

    >
    > As you're posting on a group about standard C, much of what you mention
    > is off topic.  Some of it might be topical on the gcc-help mailing list
    > (subscribe athttp://gcc.gnu.org).
    > MSC has little C99 support, while gcc has a fair amount, including,
    > contrary to your assertion, long long int.
    > The LP64 model on 64-bit linux implies 64-bit long int and pointer data
    > types.  On 32-bit linux, those are 32-bit data types, according to ILP32
    > model.  <stdint.h> is available in gcc.


    I didn't know that gcc supported a long long int. I'd be curious to
    find out the motivation for that as it appears that it is not so as to
    comply to the standard.

    My experience with the Evil Empire is that it was less standard-
    noncompliant than I would have thought when it got down to brass
    tacks. Usually just non-standard headers.
    Frank, Jul 31, 2009
    #4
  5. <> wrote:
    >I'm interested to know what is the difference in programming using MS
    >Visual C++ on Windows and using the GCC compiler on Linux, i.e. what
    >are some of the things I can do on Visual C++ that won't compile/run on
    >Linux, and vice versa.


    The list is probably about 18 million miles long. Single-spaced. ;)

    >For example, I know that Windows uses the LLP64 model, while Linux uses
    >the LP64 model, so I can't use the long long data type when programming
    >on Linux.


    This is the least of your worries--GCC will compile long long (8 bytes)
    just fine, even on a 32-bit system.

    >Also, the windows.h file is only available in Windows, and can't be
    >used on Linux. I've also read that there is also some differences in
    >network programming, since winsock, and especially the underlying ip
    >headers are much different in Windows than Unix/ Linux gcc. Is this
    >true?


    Yes, yes, and yes. Again, this is just the tip of the iceberg.

    Search Google for porting windows linux and you'll get all kinds of
    hits. Microsoft has a page that seems pretty useful as a starting point:

    http://msdn.microsoft.com/en-us/library/y23kc048(VS.80).aspx

    If you're developing something from scratch and want it to run on
    multiple platforms (in this case I mean Win/Unix/OSX), choose a set of
    libraries that provide the functionality you need and build with minimal
    reworking for each platform. Some popular examples of libraries like
    this are OpenGL, OpenAL, SDL, and wxWidgets, but there are plenty more
    and people have their favorites.

    Oh, and as always try to write as much standard C as possible, while
    wrapping up the non-portable bits.

    -Beej
    Beej Jorgensen, Jul 31, 2009
    #5
  6. Nobody Guest

    On Thu, 30 Jul 2009 21:20:01 -0700, wrote:

    > I'm interested to know what is the difference in programming using MS
    > Visual C++ on Windows and using the GCC compiler on Linux, i.e. what
    > are some of the things I can do on Visual C++ that won't compile/run
    > on Linux, and vice versa.
    >
    > For example, I know that Windows uses the LLP64 model, while Linux
    > uses the LP64 model, so I can't use the long long data type when
    > programming on Linux.


    1. Yes you can.
    2. LLP64 means that *only* "long long" and pointers are 64 bits, while
    "long" is 32 bits. LP64 means that "long" and pointers are 64 bits.

    Win64 uses a 32-bit "long" for binary compatibility with Win32. Unix tends
    to be more concerned with source compatibility than binary compatibility,
    so it isn't considered a problem to have a 32-bit "long" on 32-bit systems
    and a 64-bit "long" on 64-bit systems.

    > Also, the windows.h file is only available in
    > Windows, and can't be used on Linux. I've also read that there is also
    > some differences in network programming, since winsock, and especially
    > the underlying ip headers are much different in Windows than Unix/
    > Linux gcc. Is this true?


    Those aren't C language issues.
    Nobody, Jul 31, 2009
    #6
  7. Amandil Guest

    On Jul 31, 4:05 am, Frank <> wrote:
    > On Jul 30, 9:44 pm, Tim Prince <> wrote:
    >
    >
    >
    > > wrote:

    >
    > > > I'm interested to know what is the difference in programming using MS
    > > > Visual C++ on Windows and using the GCC compiler on Linux, i.e. what
    > > > are some of the things I can do on Visual C++ that won't compile/run
    > > > on Linux, and vice versa.

    >
    > > > For example, I know that Windows uses the LLP64 model, while Linux
    > > > uses the LP64 model, so I can't use the long long data type when
    > > > programming on Linux. Also, the windows.h file is only available in
    > > > Windows, and can't be used on Linux. I've also read that there is also
    > > > some differences in network programming, since winsock, and especially
    > > > the underlying ip headers are much different in Windows than Unix/
    > > > Linux gcc.

    >
    > > As you're posting on a group about standard C, much of what you mention
    > > is off topic.  Some of it might be topical on the gcc-help mailing list
    > > (subscribe athttp://gcc.gnu.org).
    > > MSC has little C99 support, while gcc has a fair amount, including,
    > > contrary to your assertion, long long int.
    > > The LP64 model on 64-bit linux implies 64-bit long int and pointer data
    > > types.  On 32-bit linux, those are 32-bit data types, according to ILP32
    > > model.  <stdint.h> is available in gcc.

    >
    > I didn't know that gcc supported a long long int.  I'd be curious to
    > find out the motivation for that as it appears that it is not so as to
    > comply to the standard.


    I may be wrong (I haven't been around the block that often), but I
    believe gcc had long long a long long time ago, and it may be that the
    standard adopted the long long from gcc.

    (please wait while I google "history long long data type"...)
    First result:
    > Subject: Re: long longs in c
    > From: (John R. Mashey)
    > Date: Aug 16 1995
    > Newsgroups: comp.lang.c
    >
    > In article <40g7uj$>,
    > (Sandy Morton) writes:
    > > Organization: Hewlett-Packard Company,
    > > Technology Solutions Lab
    > >
    > > In article <danpop.808147613@rscernix>,
    > > (Dan Pop) writes:
    > >> long long is not a C feature. Compiler specific
    > >> questions belong to
    > >> system specific newsgroups, in this case
    > >> comp.sys.hp.hpux.

    > >
    > > Okay. I'm not arguing with you and I plan to post
    > > my problem there as well.
    > > But ... are you sure about long longs not being a C
    > > feature? I was under the impression they were being
    > > added to the ansi standard (thus the reason
    > > HP is implementing them). They are still very new,
    > > and until HP's 10.0
    > > ...

    >
    > 1) long longs are not part of ANSI C ... but probably
    > will be, since:
    > 2) They are implemented by many vendors. 3 years ago,
    > there was an informal working group that included
    > many vendors, (addressing 64-bit C progrmaming
    > models for machines that also had 32-bit models),
    > and the general consensus was that as much as we
    > despised the syntax, it was:
    > a) Already in CONVEX & Amdahl, at least
    > b) Already in Gnu C
    > c) And various other hardware vendors either
    > already had it in or were planning to.
    > Somebody in this group was also on ANSI C committee,
    > and observed that fact of long long not being in ANSI
    > C was no reason not to agree on doing it, since
    > standards generally codify existing practice, rather
    > than inventing new things, when reasonably possible.
    > 3) On SGI, printf long long uses %lld. I don't
    > know what others do.


    So, yes, gcc has had long long since 1992 as an extension.

    -- Marty Amandil
    (Insert your favorite humorous quote here)
    Amandil, Jul 31, 2009
    #7
  8. Amandil Guest

    On Jul 31, 4:31 pm, Amandil <> wrote:
    > On Jul 31, 4:05 am, Frank wrote:
    > > On Jul 30, 9:44 pm, Tim Prince wrote:
    > > > wrote:
    > > > > I'm interested to know what is the difference in

    <snip>
    > > I didn't know that gcc supported a long long int.  I'd be
    > > curious to find out the motivation for that as it appears
    > > that it is not so as to comply to the standard.


    A link to the discussion my upthread comment quotes (sorry, I
    don't know a better way to supply a link):
    http://groups.google.com/group/comp...0/adaad1e17f354e76?lnk=st&q=#adaad1e17f354e76

    -- Mary Amandil
    Amandil, Jul 31, 2009
    #8
  9. Guest

    On Jul 31, 11:53 am, Nobody <> wrote:
    > Win64 uses a 32-bit "long" for binary compatibility with Win32. Unix tends
    > to be more concerned with source compatibility than binary compatibility,
    > so it isn't considered a problem to have a 32-bit "long" on 32-bit systems
    > and a 64-bit "long" on 64-bit systems.



    Actually the 32 bit longs are for source portability on Win64. Far
    too many Win32 application have assumptions about the size of long,
    thus keeping long 32 bits breaks less code when porting to Win64.
    Most *nix application have had more exposure to varying architectures,
    and likely adapt better to changes in sizes of the types.
    , Jul 31, 2009
    #9
  10. A project advice I give you if you want to port your system:

    Find out what´s OS dependent, and compile that separately. That way
    when
    you change operating systems, you know exactly what you have to work
    on,
    and what you can leave intact.
    Rafael Anschau, Jul 31, 2009
    #10
  11. Frank Guest

    On Jul 31, 1:44 pm, Amandil <> wrote:
    > On Jul 31, 4:31 pm, Amandil <> wrote:
    >
    > > On Jul 31, 4:05 am, Frank wrote:
    > > > On Jul 30, 9:44 pm, Tim Prince wrote:
    > > > > wrote:
    > > > > > I'm interested to know what is the difference in

    > <snip>
    > > > I didn't know that gcc supported a long long int.  I'd be
    > > > curious to find out the motivation for that as it appears
    > > > that it is not so as to comply to the standard.

    >
    > A link to the discussion my upthread comment quotes (sorry, I
    > don't know a better way to supply a link):http://groups.google.com/group/comp.std.c/browse_thread/thread/404ea4...
    >
    > -- Mary Amandil


    yikes. bad interface. I've got a kapscha screen that is a 50-50
    preposition. Tja.

    My comment was that the extension of long long to gcc shows at least
    one side of how ms and gcc are remakably similar under the hood.

    Blessed Sabbath, cheers.
    Frank, Aug 2, 2009
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jakk
    Replies:
    4
    Views:
    12,060
  2. Private
    Replies:
    2
    Views:
    488
    Michael Borgwardt
    Dec 11, 2004
  3. Replies:
    6
    Views:
    382
  4. Rayne
    Replies:
    11
    Views:
    1,135
  5. Johannes Schaub (litb)

    Weird difference between comeau and gcc/clang

    Johannes Schaub (litb), Oct 13, 2010, in forum: C++
    Replies:
    15
    Views:
    584
    James Kanze
    Oct 18, 2010
Loading...

Share This Page