main.c
#include "stackg.h"
int main()
{
return 0;
}
stackg.h
#ifndef STACKG_H
#define STACKG_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct stack_gt* stack_gt;
stack_gt stkg_init(
void* (*alloc)(const void* data, const int size),
void (*dealloc)(void* data),
void (*copy)(void* data_d, const void* data_s),
const int size
);
void stkg_free(stack_gt s);
int stkg_is_empty(stack_gt s);
int stkg_is_full(stack_gt s);
const int stkg_size(const stack_gt s);
void stkg_clear(stack_gt s);
int stkg_push(stack_gt s, const void* data);
int stkg_pop(stack_gt s, void* data);
int stkg_peek(stack_gt s, void* data);
#ifdef __cplusplus
}
#endif
#endif
上面的程序用 GCC 编译器编译成功,但是在 MSVC2008 中它给出了以下错误:
error C2040: 'stack_gt *' differs in levels of indirection from 'stack_gt'
我应该告诉 MSVC 什么让它编译程序而不更改代码中的任何内容?
编辑
错误发生在stackg.h
::的第 8 行typedef struct stack_gt* stack_gt;
编辑 2
如果没有别的,我会去typedef struct _stack_gt* stack_gt;