Compiling C: What Do Experts Use?

  • Thread starter Bob Busby
  • Start date
In summary, using an IDE can be helpful, but if you are familiar with the command line, you will be fine.
  • #1
Bob Busby
47
0
IDEs are bloated and slow usually and makefiles are confusing to write by myself. I was just wondering what you experts do to organize and compile projects with.
 
Technology news on Phys.org
  • #2
I use vi, make and gcc. But I am an old-timer, wouldn't recommend it to anyone else.
 
  • #3
Depends on how complex the project is. Note that Visual Studio includes a dos console window under programs / ... visual studio ... / tools, where you can use cl and link (and ml if you want to do assembly programs). If it's just a single module, I just use cl. If it's a few modules, I create a batch file.

For the most complex setup I've used at work, the user can create an empty directory and get a single batch file that will get everything needed from version control and do a build. In some cases that same batch file can be used with an existing directory, only updating anything that is out of date (mostly makefile). The batch file gets the build tools, (nmake, ml, cl, link, ...), via version control, sets environment variables, creates the entire directory tree, then switches to a large makefile that gets source files if not present or out of date, then does the actual build process. The build tools are included so that old code is built with the same versions of the tools used to originally build the old code.

One trick in the batch file for real dos or dos console windoes to allow it to be used with either empty or existing directories is the ability to test for the existence of a directory by looking for a file named "nul" in that directory:

Code:
if not exist exampledirectory\nul    md exampledirectory

I don't recall being able to duplicate this with an makefile, but once the directories are created, then the makefile has no problem checking for existence of files or out of date files.

In addition to visual studio, old copies of visual c 4.0 (32 bit) and 2.2 (16 bit), are used to work with old projects.
 
Last edited:
  • #4
Bob Busby said:
IDEs are bloated and slow usually and makefiles are confusing to write by myself. I was just wondering what you experts do to organize and compile projects with.

You should understand that many IDE's call separate processes that compile different source files and link these modules to create an EXE, DLL, or other binary object.

Usually what can happen is that the IDE calls these processes and simply pipes the output to an output window of some sort.

If you have a decent computer (not top of the line, but average), this should not be a major issue.
 
  • #5
MarcoD said:
I use vi, make and gcc. But I am an old-timer, wouldn't recommend it to anyone else.
Also an old-timer, so take my comments with a grain of salt.

vi/vim can be fairly magical, particularly when you have magic enabled. On the other hand, vim (who uses vi nowadays?) is a rather dimwitted editor, even with ctags (which don't work quite so well with an OO language where names intentionally overlap). I like the command line concept in vim versus the popups that tend to pervade IDEs; I find that those popups to be slow, distracting, and disconcerting. Some people justifiably do like the added power of an IDE, and find the modal behaviors of vi, vim and emacs to be distracting and disconcerting.

Regarding makefiles, I sometimes have to use external tools that write makefiles. (Using an IDE in these situations can be a bit tough, when the external tool and the IDE contend over who owns the makefile.) When I am in control, if the makefile is simple I just write the makefile. If the makefile will be of any complexity, I will either
  • include some master makefile I have written earlier and add the few lines need to make that master makefile work. I find this approach to be very useful for unit tests. My unit test makefiles tend to be very small thanks to the include capability.
  • Build a Configure script that generates a top level makefile in some project. This top level makefile will inevitably contain a makefiles target that invokes some secondary script to build makefiles in applicable subdirectories, each of which has a makefiles target as well.
    The underlying machinery can be a bit convoluted, but usage is simple: Just type make.
 
  • #6
I remember back when I started learning to program using QB and Assembler/Machine code you had to do all the compiling and linking of stuff by hand (The assembler stuff) and when I first used Windows Visual Studio 6, it was like the transition of going from a TV without a remote to with one.

The only thing I've used in a *nix environment was pico. I'm not a linux user anyway, but at least with pico you could telnet into the environment from a windows machine and the graphics environment with pico was all hunky-dory! I remember when I used emacs on the telnet session, everything went to crap. This was for remote compilation for uni-work quite a while back though.
 

1. What is the purpose of compiling C code?

The purpose of compiling C code is to translate the human-readable code written by a programmer into machine-readable instructions that can be executed by a computer. This allows the computer to understand and run the program.

2. What tools do experts use to compile C code?

Experts typically use a compiler, such as GCC or Clang, to compile C code. They may also use a text editor or integrated development environment (IDE) to write and organize their code.

3. Can C code be compiled on any operating system?

Yes, C code can be compiled on any operating system as long as the appropriate compiler is installed. However, the resulting executable file may only run on the specific operating system it was compiled for.

4. How does the compilation process work?

The compilation process involves several steps, including preprocessing, compiling, assembly, and linking. In preprocessing, the code is checked for any syntax errors and any preprocessor directives are processed. Then, in compiling, the code is translated into assembly language. The assembly code is then translated into machine code in the assembly step. Finally, the linker combines all the necessary files and libraries to create an executable file.

5. Are there different types of C compilers?

Yes, there are different types of C compilers, including cross-compilers, which can compile code for a different target platform than the one it is running on, and optimizing compilers, which can improve the performance of the resulting executable by rearranging and optimizing the code.

Similar threads

  • Programming and Computer Science
Replies
12
Views
2K
Replies
6
Views
1K
  • Programming and Computer Science
Replies
2
Views
339
  • Programming and Computer Science
Replies
20
Views
2K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
17
Views
1K
  • Programming and Computer Science
2
Replies
59
Views
5K
  • Programming and Computer Science
Replies
13
Views
2K
  • Programming and Computer Science
Replies
14
Views
2K
  • Programming and Computer Science
Replies
6
Views
8K
Back
Top