Angband Forums

Angband Forums (http://angband.oook.cz/forum/index.php)
-   Development (http://angband.oook.cz/forum/forumdisplay.php?f=10)
-   -   Compiling with VS2015 (http://angband.oook.cz/forum/showthread.php?t=8346)

Siemelink April 11, 2017 23:09

Compiling with VS2015
 
1 Attachment(s)
Hi all,
I am trying to compile 4.0.5 with microsoft visual studio community 2015. I am getting loads of errors.
There is the old instruction to compile, it is not quite accurate. My exact project settings are in the attachment.

1)
I've added all the .h and .c files, the files in the win folder. When I compile i receive eror: macro definition of snprintf conflicts with Standard Library function declaration

This code seems outdated, so I've commented it out snprintf:
/**
* Native MSVC compiler doesn't understand inline or snprintf
*/
#ifdef _MSC_VER
# define inline __inline
//# define snprintf _snprintf
#endif

2)
Next, I get that pwd.h is not added. But I find the #include <pwd.h>under UNIX, while I am trying to compile as WINDOWS

So I've added || defined(_MSC_VER) to gain:
/**
* Extract the "WINDOWS" flag from the compiler
*/
# if defined(_Windows) || defined(__WINDOWS__) || \
defined(__WIN32__) || defined(WIN32) || \
defined(__WINNT__) || defined(__NT__) || defined(_MSC_VER)
# ifndef WINDOWS
# define WINDOWS
# endif
# endif

3)
now I am left with 100s of errors. I like this one:

static const int list_size = 64;
const char *initial_pronoun;
const char *name_list[list_size];

"Expression (list_size) must have constant value," which has been defined just two lines above!

There is probably something obvious that I missed. Does someone have a clue?

Thanks, Willem.

Pete Mack April 11, 2017 23:51

MSVC is known not to be fully compliant in c99. You can change the const int to a #define with no bad effects.

t4nk April 12, 2017 00:29

Maybe just don't use a C++ compiler to compile a program that is not written in C++

Pete Mack April 12, 2017 03:44

MSVC does work for C, it just never was updated fully to later standards. I don't know why. Adding that kind of thing to a compiler is pretty easy.

Siemelink April 12, 2017 23:26

Quote:

Originally Posted by Pete Mack (Post 119880)
MSVC does work for C, it just never was updated fully to later standards. I don't know why. Adding that kind of thing to a compiler is pretty easy.

Yes, I've been using MSVC for over a decade to compile angband.

It does not seem to like nested typedefs, #typedef char bool gives errors where bool is used. If I replace bool with char, it does compile. But clearly doing that throughout the code is not optimal.

Willem.

Pete Mack April 12, 2017 23:56

MSVC doesn't have stdbool.h
You can write your own, then add -I. to the compile line.
http://stackoverflow.com/questions/5...s2010-question

t4nk April 13, 2017 00:58

Quote:

Originally Posted by Pete Mack (Post 119880)
MSVC does work for C

For some definition of "C"...

Quote:

it just never was updated fully to later standards. I don't know why.
https://docs.microsoft.com/en-us/vis...ivot=languages
Pretty self-explanatory, IMO...

AnonymousHero April 13, 2017 02:00

I feel that this the perfect moment to chime in and say that Angband should convert to C++. C'mon, people!

/trolling

EDIT: FWIW, the quality of the MS compilers for C or C++ are appalling. (I mean they're trying to catch up... and getting a lot better, but they're still nowhere near Clang or GCC in terms of rapid compliance to new standards.)

t4nk April 13, 2017 02:14

Quote:

Originally Posted by AnonymousHero (Post 119921)
I feel that this the perfect moment to chime in and say that Angband should convert to C++. C'mon, people!

Well that's not a bad idea. It might not be a practical idea, but I do think C++ is more appropriate for software like Angband (even though it's a horrible language :cool:)
Actually, you know what. How about converting it to D :cool:

Derakon April 13, 2017 03:25

Quote:

Originally Posted by t4nk (Post 119922)
Actually, you know what. How about converting it to D :cool:

C++ makes a modicum of sense here because you can do the upgrade piecemeal. If you're going to completely rewrite the game in a different, incompatible language, you might as well do a top-down redesign. And write it in Python. Oh look, it's Pyrel again. Too bad I ran out of steam before getting it all the way finished.


All times are GMT +1. The time now is 03:15.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.