views:

57

answers:

3

Hi,

I'm trying to compile an open source project I downloaded, apparently written in VC++ 7.1.

After alot of trouble, being novice at C++, I managed to download and fix includes for STLPort that the project uses. However, I get something like 15000 errors that complains that certain types are not defined. A few of them are:

u_int32_t
int64_t
u_int16_t
u_int8_t

etc. After a bit of googling I figured out they are added in C99? It is a fact that other developers before me has managed to compile it using VC. I'm using VC 10 though.

The project has been dead for a few years, so I cannot contact the author.

Thanks!

+3  A: 

The Visual C++ compiler does not support most C99 features.

If you want to use the standard fixed-width integer types, you need to make sure you include <cstdint> and qualify them with std:: or include <stdint.h>.

The standard fixed-width unsigned type names are uint32_t, uint16_t, and uint8_t (that is, there is no _ between the u and int). You can, of course, typedef your own types if you want to (while you should use the standard typedefs for new code, you may need to typedef your own to interoperate with legacy code).

James McNellis
Or use boost/cstdint, although it's easy enough to get hold of a version of plain `stdint.h` for Windows, if MSVC still doesn't include one.
Steve Jessop
What is the easiest way to make these typedefs extend to all source/header files?
Max Malmgren
@Steve: The standard library shipped with Visual C++ 2010 includes `<cstdint>`.
James McNellis
@James: oh good. Took their time, but got there eventually :-)
Steve Jessop
@Max: Create a header with all of these typedefs in it and include that header in all the files that need it. If you don't want to modify the files, you can define the types as macros on the command line (that's messier, but allows you not to have to edit the files).
James McNellis
Just to keep in mind (you know, in case there's a major CPU architecture revolution at some point ;p): The `intN_t` and `uintN_t` typedefs aren't guaranteed to exist, but the `intNleast_t` and `uintNleast_t` are.
Steve M
A: 

You need to install a compatible C99 compiler and libraries, and the point the VC++10 environment at those.

However I suspect the easier way to find the build/make files and use those.

Preet Sangha
What would be a sufficient compiler compatible with VC 10?
Max Malmgren
+1  A: 

It's pretty easy to define these types for yourself in Visual Studio, since they offer __int(bitsize) functionality.

typedef __int64 int64_t;
typedef unsigned __int32 u_int32_t;
typedef unsigned __int16 u_int16_t;
typedef unsigned __int8 u_int8_t;
DeadMG