Typedef缺少类型说明符

时间:2015-08-17 01:34:44

标签: c

#pragma once

#include <stdio.h>

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

#define false 0
#define true 1

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

typedef uint32_t uint32;

void Update(void);
void Render(void);

>------ Build started: Project: Shattered, Configuration: Debug x64 ------
1>  main.c
1>  shattered.cpp
1>c:\users\zak\desktop\shattered\shattered\shattered.h(12): error C2146: syntax error : missing ';' before identifier 'int8'
1>c:\users\zak\desktop\shattered\shattered\shattered.h(12): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\zak\desktop\shattered\shattered\shattered.h(13): error C2146: syntax error : missing ';' before identifier 'int16'
1>c:\users\zak\desktop\shattered\shattered\shattered.h(13): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\zak\desktop\shattered\shattered\shattered.h(14): error C2146: syntax error : missing ';' before identifier 'int32'
1>c:\users\zak\desktop\shattered\shattered\shattered.h(14): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\zak\desktop\shattered\shattered\shattered.h(15): error C2146: syntax error : missing ';' before identifier 'int64'
1>c:\users\zak\desktop\shattered\shattered\shattered.h(15): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\zak\desktop\shattered\shattered\shattered.h(16): error C2146: syntax error : missing ';' before identifier 'bool32'
1>c:\users\zak\desktop\shattered\shattered\shattered.h(16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\zak\desktop\shattered\shattered\shattered.h(16): error C2378: 'int32' : redefinition; symbol cannot be overloaded with a typedef
1>          c:\users\zak\desktop\shattered\shattered\shattered.h(14) : see declaration of 'int32'
1>c:\users\zak\desktop\shattered\shattered\shattered.h(18): error C2146: syntax error : missing ';' before identifier 'uint32'
1>c:\users\zak\desktop\shattered\shattered\shattered.h(18): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

所以这是我的代码,我得到的输出是说它不知道int8的类型,当我明确包含stdio.h时。

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:3)

你应#include <stdint.h>对这些类型有定义。