0

I'm working on compiling NetHack in Visual Studio 2015 on Windows 7.

I'm getting the following error (all preceded with c:\program files (x86)\windows kits\10\include\10.0.10586.0\um\memoryapi.h:

3>(815): error C2143: syntax error: missing ')' before '.'
3>(815): error C2059: syntax error: ')'
3>(816): error C2059: syntax error: ')'

Here is the context in the source:

805 #if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
806 
807 WINBASEAPI
808 _Ret_maybenull_ _Post_writable_byte_size_(Size)
809 PVOID
810 WINAPI
811 VirtualAllocFromApp(
812    _In_opt_ PVOID BaseAddress,
813    _In_ SIZE_T Size,
814    _In_ ULONG AllocationType,
815    _In_ ULONG Protection
816    );

This is confusing because #1, there's a compiler directive that is supposed to prevent this section of code from being used--I'm running Windows 7, and #2, the first error, missing ')' before '.' makes no sense because there is no . in the source code. How do I proceed?

When I search the whole solution for _WIN32_WINNT Visual Studio can't find it—bizarre! I did find WINPFLAG = -DTILES -DMSWIN_GRAPHICS -DWIN32CON -D_WIN32_IE=0x0400 -D_WIN32_WINNT=0x0501. However, _WIN32_WINNT_WIN10 doesn't appear to be defined, though presumably it's defined by the system (?). Trying to define it myself as 0x0A00, but uncommenting the above code yielded the same errors again.

Now I'm getting Error C2733 'terminate': second C linkage of overloaded function not allowed NetHack nethack\include\extern.h 643 :

E void FDECL(terminate, (int)) NORETURN;

I searched the whole solution again with Notepad++ and this is the only occurrence (strangely, VS itself is still having problems finding these things with global search).

ErikE
  • 48,881
  • 23
  • 151
  • 196
  • Try looking in the lines prior to 805, I suspect that there is an construct that is throwing things off. It finally gets reported on the indicated line. My hunch is that if you comment out the conditional block, you will get an error somewhere else in the program. Without seeing the code in its entirety, it is hard to tell – thurizas Aug 07 '16 at 23:30
  • When I comment out that section of code (only the part inside the `#if`, I no longer get the error. But now I'm getting a new error. Sigh. – ErikE Aug 07 '16 at 23:45
  • what is that error? – thurizas Aug 08 '16 at 00:11
  • and also a thought, how are `_WIN32_WINNT` and `_WIN32_WINNT_WIN10` defined? – thurizas Aug 08 '16 at 00:13
  • @thurizas I updated my question again. It seems like i'm getting really close. I had a lot of missing files errors at first and had to locate them and get references fixed, etc. – ErikE Aug 08 '16 at 01:15
  • If the macro is undefined [it is treated as the value 0](http://stackoverflow.com/questions/5085392/what-is-the-value-of-an-undefined-constant-used-in-if?noredirect=1&lq=1), and of course `0 >= 0` is true. – Bo Persson Aug 08 '16 at 01:46
  • Where should it be defined? Aren't the comparison values Windows ones? Is it just a switch I pass in? I tried it and the error still occurred. – ErikE Aug 08 '16 at 02:24
  • _WIN32_WINNT should be defined in the project (possible targetver.h) see https://msdn.microsoft.com/en-us/library/6sehtctf.aspx. – thurizas Aug 08 '16 at 14:56
  • I've downloaded net-hack-3.6.0, and the only place that _WIN32_WINNT appears is in `WINPFLAG = -DTILES -DMSWIN_GRAPHICS -DWIN32CON -D_WIN32_IE=0x0400 -D_WIN32_WINNT=0x0501`, which is found in the file sys/winnt/Makefile.gcc – thurizas Aug 08 '16 at 15:23
  • @thurizas Hmmm but my question is whether the specific versions are defined in the compiler in order to be compared to. – ErikE Aug 08 '16 at 15:47
  • looking at the project settings (Properties | C/C++ | Preprocessor) for NetHackW, I don't see either of these being defined. Trying the compilation with Visual Studio 2010, ten of the twelve projects compile out of the box. The first to fail was 'tiles', failed because the build system could not find `tile2bmp.exe` and the second was 'NetHackW' failed because `rc` couldn't find tiles.bmp --- I strongly suspect that the second failure is a consequence of the first. Assuming I go the source from where you did, the say that buiding is only supported on VS2010 and VS2013 - might try one of them – thurizas Aug 08 '16 at 16:10
  • That's a good idea to start with. Thanks – ErikE Aug 08 '16 at 16:28

0 Answers0