Author Topic: # if _MSC_VER >= 1400  (Read 377 times)

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 65
# if _MSC_VER >= 1400
« on: July 09, 2017, 03:21:58 pm »
Just found this in one program

Code: [Select]
#  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?
« Last Edit: July 09, 2017, 03:23:47 pm by visir »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10371
Re: # if _MSC_VER >= 1400
« Reply #1 on: July 09, 2017, 04:19:21 pm »
Disable the editor feature that greys out preprocessor directives...
<debugger plugin maintainer>
(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!]

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 65
Re: # if _MSC_VER >= 1400
« Reply #2 on: July 09, 2017, 04:38:58 pm »
That is indeed a suggestion, but...

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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10371
Re: # if _MSC_VER >= 1400
« Reply #3 on: July 09, 2017, 05:26:16 pm »
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.
<debugger plugin maintainer>
(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!]

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 65
Re: # if _MSC_VER >= 1400
« Reply #4 on: July 09, 2017, 05:40:21 pm »
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10371
Re: # if _MSC_VER >= 1400
« Reply #5 on: July 09, 2017, 05:49:19 pm »
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
<debugger plugin maintainer>
(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!]

Offline visir

  • Multiple posting newcomer
  • *
  • Posts: 65
Re: # if _MSC_VER >= 1400
« Reply #6 on: July 09, 2017, 09:11:58 pm »
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.