learning C, working around code for different compilers

Reply

Join Date: Dec 2004
Posts: 35
Reputation: serfurj is an unknown quantity at this point 
Solved Threads: 2
serfurj's Avatar
serfurj serfurj is offline Offline
Light Poster

learning C, working around code for different compilers

 
0
  #1
Dec 10th, 2004
i've been reading a lot of the posts here to help me learn C. the problem is, much of the code is written for other compilers (i use gcc). i didn't know there was compiler-specific code until i tried to compile code from questions asked here.

this seems so backwards, coming from a background in interpreted languages. please shed some light on the issue.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,614
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 713
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: learning C, working around code for different compilers

 
0
  #2
Dec 10th, 2004
There's a language standard that compilers are pretty much required to support if they want any market share, but the language definition also allows for non-standard extensions. Every compiler out there will take advantage of this allowance, so code that uses extensions will not be portable across compilers. The same goes with system APIs and third party libraries. However, if you use the standard language, your code should compile everywhere and run as expected.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 35
Reputation: serfurj is an unknown quantity at this point 
Solved Threads: 2
serfurj's Avatar
serfurj serfurj is offline Offline
Light Poster

Re: learning C, working around code for different compilers

 
0
  #3
Dec 10th, 2004
i wonder why anyone would want to write non-standard code.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,985
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 927
Moderator
vegaseat's Avatar
vegaseat vegaseat is online now Online
DaniWeb's Hypocrite

Re: learning C, working around code for different compilers

 
0
  #4
Dec 11th, 2004
Depending whom you work for, there might be a favorite compiler in the shop. Many schools teach on old and outdated compilers, often teachers are most reluctant to change and rewrite their material, the list goes on ...

I have found the Dev C++ IDE reasonably generic in the Windows and Linux world, conforming to most C++ standards with their GCC/G++ combination of compilers.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: learning C, working around code for different compilers

 
0
  #5
Dec 11th, 2004
Not just that, but unless you want to limit yourself to a very small library of functions indeed you're going to have to use compiler specific libraries at some point.
The trick is to use those libraries in such a way that the largest possible part of your code does not directly depend on them.

Example are GUI libraries. Those are pretty much all at least platform specific and often compiler specific as well.
Network libraries are the same, IO handling often as well (if you want more control than scanf and printf can handle).

gcc is no more generic than any other compiler, in fact it has a lot more platform specific libraries and some others and the documentation is often lacking.
In fact, Borland has always had the most standard compliant of all compilers on i386 platforms and a reasonably well marked custom library.
They also provide excellent documentation.

As to teachers being reluctant to change their material, often they aren't even aware they're using non-standard extensions, having learned C (or whatever) from the same book (Learning C in 21 days using Turbo C 1.5) they use to teach their students and never reading anything else.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 35
Reputation: serfurj is an unknown quantity at this point 
Solved Threads: 2
serfurj's Avatar
serfurj serfurj is offline Offline
Light Poster

Re: learning C, working around code for different compilers

 
0
  #6
Dec 11th, 2004
thanks for the replies. i think i'm going to buy "C Programming Language : ANSI C Version, by Brian W. Kernighan, Dennis Ritchie".
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC