Tutorial :Why is -o a candidate for deletion from the Microsoft compiler and linker?



Question:

I came across the following and I am wondering what implications it is going to have on my cygwin/gnu environment should I be using something other than -o to name the output from a compile? Has there been some new standard adopted and do other compilers adhere to it?

What would be the motivation for removing -o?

DOS PROMPT>type compile.bat

cl.exe -D YY_MAIN=1 lex.yy.c libfl.obj -o foobar

DOS PROMPT>compile

cl.exe -D YY_MAIN=1 lex.yy.c libfl.obj -o foobar  Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86  Copyright (C) Microsoft Corporation.  All rights reserved.  lex.yy.c  Microsoft (R) Incremental Linker Version 9.00.21022.08  Copyright (C) Microsoft Corporation.  All rights reserved.  /out:lex.yy.exe  /out:foobar.exe  lex.yy.obj  libfl.obj  

cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release

Update: As the answer below asks Are they trying to make more of a rift between Windows and UNIX intentionally? I hope not. I am hoping I am missing some new convention adopted by all the compilers out there.


Solution:1

I wouldn't necessarily see a nefarious purpose behind that - it's more likely to be some compatibility-related thing (perhaps -o is interfering with some build system or the other used by some big Microsoft customer or the other.)

However, it is annoying when a compiler vendor throws away entrenched practices and learned reflexes.

But the (syntactical and philosophical) differences between the Microsoft compilers and the Unix compilers are bigger than a simple command line switch. To that end, you could try to step away from simple batch build scripts and towards Makefiles - or, better yet, an actual cross-platform build system such as CMake or SCons (please note that they're just examples, I'm not married to any of them :) ).


Solution:2

Command line arguments on Windows are different than command line arguments on Unix. They usually start with a / instead of a -, and the arguments to cl.exe won't necessarily match those of cc on Unix.

Looks like the option you're looking for is /Fe


Solution:3

Yes. You should use /F to set compiler output options.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »