mercredi 26 août 2015

Typedef doesn't work in included file

I have this code:

#include <stdint.h>

#define internal static
#define local_persist static
#define global_variable static

#define Pi32 3.14159265359f

typedef int8_t int8;
typedef int16_t int16;
typedef int32_t int32;
typedef int64_t int64;
typedef int32 bool32;

typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;

typedef float real32;
typedef double real64;

#include "someheader.h"
// etc

And in the someheader.h file I have:

struct game_sound_output_buffer
{
    int16* Samples;
    int SampleCount;
    int SamplesPerSecond;
};

I am using Visual Studio and I get these errors on the line with the int16* variable:

error C2143: syntax error : missing ';' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Why does this happen? I typedefed before including the header file. And the weirder thing, it works fine if I compile from the command line

cl -FC -Zi file.cpp user32.lib Gdi32.lib

Aucun commentaire:

Enregistrer un commentaire