views:

292

answers:

3

My definition of powerful is ability to customize.

I'm familiar with gcc I wanted to try MSVC. So, I was searching for gcc equivalent options in msvc. I'm unable to find many of them.

controlling kind of output

Stop after the preprocessing stage; do not run the compiler proper.
gcc: -E
msvc: ???

Stop after the stage of compilation proper; do not assemble.
gcc: -S
msvc: ???

Compile or assemble the source files, but do not link.
gcc: -c
msvc:/c

Useful for debugging

Print (on standard error output) the commands executed to run the stages of compilation.
gcc: -v
msvc: ???

Store the usual “temporary” intermediate files permanently;
gcc: -save-temps
msvc: ???
  1. Is there some kind of gcc <--> msvc compiler option mapping guide?
  2. gcc Option Summary lists more options in each section than Compiler Options Listed by Category. There are hell lot of important and interesting things missing in msvc. Am I missing something or msvc is really less powerful than gcc.
+3  A: 

Both compilers have a plethora of options for modifying... everything. I suspect that any option not present in either is an option for something not worth doing in the first place. Most "normal" users don't find a use for most of those options anyway.

If you're looking purely at the number of available options as a measure of "power" or "flexibility" then you'll probably find gcc to be the winner, simply because gcc handles many platforms other than Windows and has specific options for many of those platforms that you obviously won't find in MSVC. gcc (well, the gcc toolchain) also compiles a whole lot of languages beyond C and C++; I recently used it for Objective-C, for example.

EDIT: I'm with Dean in questioning the validity of your question. Yes, MSVC (cl) has options for the equivalent of many of gcc's options, but no, the number of options doesn't really mean much.

In short: Unless you're doing something very special, you'll find MSVC easily "powerful enough" on the Windows platform that you will likely not be missing any gcc options.

Carl Smotricz
I'm just considering C/C++ here. Even if I remove other languages from picture, there are lot more things missing like different versions of C/C++ standards. About "any option not present in either is an option for something not worth doing in the first place". Are the options I pointed out in my question not useful ones? aren't they worth doing?
claws
@claws: The options you pointed out in your question *are* useful, and other answers have pointed out the cl.exe equivalents. And different versions of C/C++ standards support would be nice. But come on, quite a few of the gcc knobs and whistles are cruft. When was the last time you played with `-fschedule-insns2`?
j_random_hacker
+8  A: 

For the equivalent of -E, cl.exe has /P (it doesn't "stop after preprocessing stage" but it outputs the preprocessor output to a file, which is largely the same thing).

For -S, it's a little murkier, since the "compilation" and "assembling" steps happen in multiple places depending on what other options you have specified (for example, if you have whole program optimization turned on, then machine code is not generated until the link stage).

For -v, Visual C++ is not the same as GCC. It executes all stages of compilation directly in cl.exe (and link.exe) so there are no "commands executed" to display. Similarly for -save-temps: because everything happens inside cl.exe and link.exe directly, the only "temporary" files are the .obj files that cl.exe produces and they're always saved anyway.

At the end of the day, though, GCC is an open source project. That means anybody with an itch to scratch can add whatever command-line options they like with relatively little resistance. For Visual C++, a commercial closed-source product, every option needs to have a business case, design meetings, test plans and so on. Every new feature starts with minus 100 points.

Dean Harding
+1 : found this helpful.
claws
I doubt everyone with an itch to scratch can just add a command line option - it's still a stable software project with maintainers that need to avoid unnecessary complexity in an already complicated piece of code. Of course, since new options *can* be added locally, it's more likely that odd experiments will be done that turn out to be useful - and that lowers the barrier to inclusion, of course.
Eamon Nerbonne
@Eamon: that's probably true. My point was mostly that it would be much harder for Microsoft to add a command-line switch for something that only a small fraction of the user-base would find useful, whereas for GCC it's not so much.
Dean Harding
+16  A: 

MSVC is an IDE, gcc is just a compiler. CL (the MSVC compiler) can do most of the steps that you are describing from gcc's point of view. CL /? gives help.

E.g.

Pre-process to stdout:

CL /E

Compile without linking:

CL /c

Generate assembly (unlike gcc, though, this doesn't prevent compiling):

CL /Fa

CL is really just a compiler, if you want to see what commands the IDE generates for compiling and linking the easiest thing to look at the the command line section of the property pages for an item in the IDE. CL doesn't call a separate preprocessor or assembler, though, so there are no separate commands to see.

For -save-temps, the IDE performs separate compiling and linking so object files are preserved anyway. To preserve pre-processor output and assembler output you can enable the /P and /Fa through the IDE.

gcc and CL are different but I wouldn't say that the MSVC lacks "a hell lot" of things, certainly not the outputs that you are looking for.

Charles Bailey