Difference between Windows and Linux GCC compiler

L

lancer6238

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.
 
T

Tim Prince

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.
 
F

Flash Gordon

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.
 
F

Frank

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.
 
B

Beej Jorgensen

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
 
N

Nobody

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.
 
A

Amandil

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 address removed) (John R. Mashey)
Date: Aug 16 1995
Newsgroups: comp.lang.c



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)
 
R

robertwessel2

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.
 
R

Rafael Anschau

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top