News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

# if _MSC_VER >= 1400

Started by visir, July 09, 2017, 03:21:58 PM

Previous topic - Next topic

visir

Just found this in one program

#  if _MSC_VER >= 1400
_sopen_s(&handle, filepath, mod | opt, (dolock ? ((mod == O_RDONLY) ? _SH_DENYRD : _SH_DENYRW) : _SH_DENYNO), _S_IREAD | _S_IWRITE);
#  else
handle = _sopen (filepath, mod | opt, (dolock ? ((mod == O_RDONLY) ? _SH_DENYRD : _SH_DENYRW) : _SH_DENYNO), _S_IREAD | _S_IWRITE);
#  endif


codeblocks highlights the first part, while debugger stops at the second one. The "_MSC_VER >= 1400" seems to mean "visual studio 2005 or older". But I'm actually using msys2. This change has this comment: "fixed all VS2005 deprecated function warnings".

What should I do with this thing, any suggestions?

oBFusCATed

Disable the editor feature that greys out preprocessor directives...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

visir

That is indeed a suggestion, but...

Let's just chat about something. About, dunno, microsoft, preprocessor.

oBFusCATed

Chat about what? The editor doesn't know about defines from project/compiler settings, neither it knows about compiler built-in defines.
Until someone implement this, it is best to just disable this feature. And btw this is not the first time some one is complaining about this.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

visir

Hm...

Any way to print out the value of _MSC_VER? Compiler probably defines it in the headers somewhere, I need to find out the exact value and copy it into #defines in project options.

oBFusCATed

This is not a good idea. Why would you want to do this? This is internal define in the compiler, bad things will happen if there is a mismatch.
Most compilers make it possible to generate the preprocessed source code instead of object files. Search the internet for details how to do this with your compiler
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

visir

Okay, it looks like _MSC_VER is undefined for me. And because it's undefined, expressions like #if _MSC_VER >= 1400 are equivalent to #if 0 >= 1400. This is actually in C and C++ standards, according to https://stackoverflow.com/questions/5085392/what-is-the-value-of-an-undefined-constant-used-in-if

Looks like there is a bug in codeblocks, if it thinks that _MSC_VER is undefined, and still thinks that _MSC_VER >= 1400 is true.

Actually whatever, I'll need to delete all those anyway.