views:

206

answers:

4

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.

+1  A: 

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

jeffamaphone
Technically you hit the answer directly but I am looking for a motivation for it.
ojblass
It's probably not evil, just some PM thought it needed to happen. Only the compiler team will know for sure.
jeffamaphone
+2  A: 

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

Brian Campbell
But why make more differences?
ojblass
Windows is a different operating system from Unix. Windows grew from DOS, which had roots in CP/M, which was inspired by the DEC family of command line environments, which used / to prefix switches on the command line. That's also where CRLF for line endings came from.
Brian Campbell
A: 

Are they trying to make more of a rift between Windows and UNIX intentionally?

Joshua
I guess it isn't a huge deal but I cannot see the motivation for it.
ojblass
+2  A: 

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 :) ).

Mihai Limbășan
I have the -o option burried deeply down inside of a rather complex structure for cross platform builds. The example was to boil it down to the simplest possible case.
ojblass
I see - that sucks then... However, there may be a lght side (or, rather, a slightly less dark side) - "will be removed in a future release" may mean @VS2025, and by then you might not need it anymore...
Mihai Limbășan