Best way to program on Linux?

This is a discussion on Best way to program on Linux? within the Tech Board forums, part of the Community Boards category; What is the best way for someone who is new to both Linux and C programming to program on Linux? ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    9

    Unhappy Best way to program on Linux?

    What is the best way for someone who is new to both Linux and C programming to program on Linux? A particular IDE or command line?

  2. #2
    Registered User
    Join Date
    May 2007
    Posts
    45
    Quote Originally Posted by dweenigma View Post
    What is the best way for someone who is new to both Linux and C programming to program on Linux? A particular IDE or command line?
    I use gcc http://en.wikipedia.org/wiki/GNU_Compiler_Collection for my compiler, its free and very easy to use, it is run through a terminal. I think all Linux distro come with this (I may be wrong here, probally am) I think you can type gcc in a terminal to see if you do, if you get an error you dont have it, but it is very easy to get.

    For learning to program theres some tutorials on this site but I find for myself a book is much more helpful than online tutorials.

  3. #3
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Linux comes with at least one C compiler usually. IDE's are useful in various circumstances, but I like a nice fancy text editor while doing everything else on a command line.

  4. #4
    Registered User
    Join Date
    Mar 2007
    Posts
    4
    You probably won't be doing anything for a long time that will warrant a big IDE with lots of advanced features. Just use one of the gazillion text editors available and stick to the terminal for all the compiling.
    Code:
    alias gcc="gcc -std=c99 -Wall -Wextra -pedantic"

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    Gcc's C99 support isn't complete yet (which is why the default mode is C90), so most people don't use -std=c99. In addition, there are a few things which are required in C90 but not in C99 (such as an explicit return statement in main()), so using C99 mode makes it less likely that code is C90 compatible. Most people try to write code that is compatible with both C90 (since it's currently the most commonly used standard) and C99 simultaneously. Someday, when compilers catch up to C99, then C90 compatibility can be thrown out the window.

  6. #6
    Registered User
    Join Date
    Jun 2005
    Posts
    5,826
    An explicit return from main() is not required in C89/C90 either, robatino. A fair few compilers, however, issue warnings if it is left out.

    Your statement "when compilers catch up to C99, then C90 compatibility can be thrown out the window" is incorrect unless only the latest compiler is used. In practice, anyone working on a non-trivial project must support a range of old and new compilers. Compilers catching up to a standard is therefore necessary but not sufficient to justify eliminating compatibility with an older standard.
    Last edited by grumpy; 05-11-2007 at 01:23 AM.

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    Are you sure? The FAQ says that an explicit return is required in main() for C89, but not in C99:

    http://faq.cprogramming.com/cgi-bin/...&id=1043284376

    Gcc appears to confirm this since if you leave out the explicit return, then with all warnings turned on it complains in C90 mode but not in C99 mode.

    Edit: The warning I get with "gcc -W -Wall -ansi -pedantic" without the explicit return in C90 mode is

    foo.c: In function ‘main’:
    foo.c:3: warning: control reaches end of non-void function

    although it doesn't explicitly say anything about ISO C90 requiring it, as it does with some other kinds of nonstandard code. If I add "-std=c99" this warning goes away.
    Last edited by robatino; 05-11-2007 at 01:36 AM.

  8. #8
    Registered User
    Join Date
    Jun 2005
    Posts
    5,826
    As sure as I can be going from memory. My copy of the C89/90 standard is in a box at work, so I don't have access to it at the moment.

    My copy of the C++ standard, which I happen to have handy, states that reaching the enclosing } of main() has the same effect as "return 0;". Annex C of the C++ standard, which lists incompatibilities between C89/90 and C++, makes no mention of anything like this. Not conclusive, I know, but production of the list of incompatibilities for information purposes was a formal requirement during the C++ standardisation process -- and I'm more inclined to believe in the content of an ISO standard over behaviour of any compiler.

  9. #9
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Your going offtopic here

  10. #10
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    zacs7: Maybe so, but if the FAQ is inaccurate it should be fixed pronto.
    grumpy: Another possibility is that in C89 the explicit return may not be required, but without it the return value may be undefined (in this case the FAQ is still inaccurate). Some googling seems to hint at this.

  11. #11
    C maniac
    Join Date
    Aug 2004
    Location
    Cyberwarping to Middle Earth
    Posts
    154
    I use Linux all the time (Debian GNU/Linux 3.1 AMD64 version with 2.6.16 kernel) and I mainly use gcc and makefiles. The text editors I use are mostly fte, vim, and Kate. Most of the time I use Kate, which is halfway between a text-editor and an IDE (BTW, I use GNOME . . .).

  12. #12
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Why are you using Kate on Gnome?, Gedit is better

    Geany is not a bad IDE for Linux (GTK)

  13. #13
    Registered User
    Join Date
    May 2007
    Posts
    17
    I'm new at Linux, too. And after using Windows for a long time, it comes a bit strange to do things in terminal. It's like using DOS command prompt in XP, which i don't like very much and find obsolete. I used to do all my work with Dev-C++ and it really made things easy for me. While trying to figure out these things, why some people especially like using command line compilers or text editors? Isn't it time consuming and unuseful? Can somebody explain me this?

    Thanks...

  14. #14
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    To me, a command line is easy to interface with and faster for most things than messing with an IDE to compile a quick test program. I write a lot of console programs anyway. Even when I write GUI programs, I like to write debug information to a console.

  15. #15
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    It also gives you a lot of control, Also you actually learn what's going on and how to compile a program.

    If you asked most Windows programmers how to compile something, they'd probably say Build -> Compile

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can't compile an SDL program under Linux
    By dwks in forum Game Programming
    Replies: 2
    Last Post: 01-16-2006, 07:51 PM
  2. Compiling a C program in Linux
    By hern in forum C Programming
    Replies: 14
    Last Post: 06-28-2004, 08:33 PM
  3. A C++ program in Solaris that cannot be ported to Linux
    By tvenki in forum C++ Programming
    Replies: 2
    Last Post: 06-11-2004, 12:13 PM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

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