Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Difference between Windows and Linux GCC compiler

Reply
Thread Tools

Difference between Windows and Linux GCC compiler

 
 
lancer6238@yahoo.com
Guest
Posts: n/a
 
      07-31-2009
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.
 
Reply With Quote
 
 
 
 
Tim Prince
Guest
Posts: n/a
 
      07-31-2009
http://www.velocityreviews.com/forums/(E-Mail Removed) 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.
 
Reply With Quote
 
 
 
 
Flash Gordon
Guest
Posts: n/a
 
      07-31-2009
(E-Mail Removed) 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
 
Reply With Quote
 
Frank
Guest
Posts: n/a
 
      07-31-2009
On Jul 30, 9:44*pm, Tim Prince <(E-Mail Removed)> wrote:
> (E-Mail Removed) 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.
 
Reply With Quote
 
Beej Jorgensen
Guest
Posts: n/a
 
      07-31-2009
(E-Mail Removed) <(E-Mail Removed)> 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/libr...48(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

 
Reply With Quote
 
Nobody
Guest
Posts: n/a
 
      07-31-2009
On Thu, 30 Jul 2009 21:20:01 -0700, (E-Mail Removed) 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.

 
Reply With Quote
 
Amandil
Guest
Posts: n/a
 
      07-31-2009
On Jul 31, 4:05*am, Frank <(E-Mail Removed)> wrote:
> On Jul 30, 9:44*pm, Tim Prince <(E-Mail Removed)> wrote:
>
>
>
> > (E-Mail Removed) 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: (E-Mail Removed) (John R. Mashey)
> Date: Aug 16 1995
> Newsgroups: comp.lang.c
>
> In article <40g7uj$(E-Mail Removed)>,
> (E-Mail Removed) (Sandy Morton) writes:
> > Organization: Hewlett-Packard Company,
> > Technology Solutions Lab
> >
> > In article <danpop.808147613@rscernix>,
> > (E-Mail Removed) (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)


 
Reply With Quote
 
Amandil
Guest
Posts: n/a
 
      07-31-2009
On Jul 31, 4:31*pm, Amandil <(E-Mail Removed)> wrote:
> On Jul 31, 4:05*am, Frank wrote:
> > On Jul 30, 9:44*pm, Tim Prince wrote:
> > > (E-Mail Removed) 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....aad1e17f354e76

-- Mary Amandil
 
Reply With Quote
 
robertwessel2@yahoo.com
Guest
Posts: n/a
 
      07-31-2009
On Jul 31, 11:53*am, Nobody <(E-Mail Removed)> 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.
 
Reply With Quote
 
Rafael Anschau
Guest
Posts: n/a
 
      07-31-2009
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird difference between comeau and gcc/clang Johannes Schaub (litb) C++ 15 10-18-2010 05:36 PM
Difference between Windows and Linux GCC compiler Rayne C++ 11 07-31-2009 03:55 PM
Linux-like GCC compiler for WIndows? adam.kleinbaum@gmail.com C Programming 6 06-24-2007 02:07 AM
what are the different between gcc and cc compiler? nick C Programming 4 10-17-2005 05:46 AM
Difference between bin and obj directories and difference between project references and dll references jakk ASP .Net 4 03-22-2005 09:23 PM



Advertisments