#include 语句出现意外错误
Unexpected Error at #include Statement
问题
当我 #include <arpa/inet.h>
Xcode 在 #include
语句生成错误 Expected identifier or '('
错误时,我试图在 BSD 套接字之上实现网络接口。
代码
snc_network.h
#ifndef __lib_Syncrology__snc_network__
#define __lib_Syncrology__snc_network__
#include "snc_def.h"
#include <arpa/inet.h>//Error Here:Expected identifier or '('
//Type Definations
typedef union
{
struct sockaddr_in6 in6_addr;
struct sockaddr_in in_addr;
struct sockaddr addr;
}snc_sockaddr_t;
#endif /* defined(__lib_Syncrology__snc_network__) */
snc_def.h
//Preprocessor Definations
#define __SYNCROLOGY_VERSION_NUMBER__ 0.0.1;
//Type Definitions
//Padding
typedef unsigned char snc_pad_t;
//Private;
typedef void snc_prv_t;
//snc Data Sturcture
typedef struct
{
uint16_t sncprot_id;
uint16_t sncprot_ref; //Refence Count
}snc_struct;
//Application Data
typedef struct
{
void *data;
size_t data_size;
}snc_appdata_t;
//Functions
//Null
bool snc_null(snc_struct *sncstruct);
//Reference Count
bool snc_retain(snc_struct *sncstruct);
void snc_release(snc_struct *sncstruct);
提前致谢。
几乎可以肯定是由于行中的错误分号
#define __SYNCROLOGY_VERSION_NUMBER__ 0.0.1;
而且,从不使用以两个下划线开头的宏。这是 C 中的未定义行为。修复该宏,并包含保护程序。
并且,从不 以 _t
结尾的变量,如果您的目标是 POSIX:它们也被保留。
这个定义
#define __SYNCROLOGY_VERSION_NUMBER__ 0.0.1;
错了,
首先不能有分号。其次,没有像 0.0.1
这样的 pp-token
即使“#define SYNCROLOGY_VERSION_NUMBER 0.0.1;”这一行的分号是不必要的,它也不应该给出编译错误吧?
尝试在 snc_def.h 之前定义 inet.h ... :)
#include <arpa/inet.h>
#include "snc_def.h"
问题
当我 #include <arpa/inet.h>
Xcode 在 #include
语句生成错误 Expected identifier or '('
错误时,我试图在 BSD 套接字之上实现网络接口。
代码
snc_network.h
#ifndef __lib_Syncrology__snc_network__
#define __lib_Syncrology__snc_network__
#include "snc_def.h"
#include <arpa/inet.h>//Error Here:Expected identifier or '('
//Type Definations
typedef union
{
struct sockaddr_in6 in6_addr;
struct sockaddr_in in_addr;
struct sockaddr addr;
}snc_sockaddr_t;
#endif /* defined(__lib_Syncrology__snc_network__) */
snc_def.h
//Preprocessor Definations
#define __SYNCROLOGY_VERSION_NUMBER__ 0.0.1;
//Type Definitions
//Padding
typedef unsigned char snc_pad_t;
//Private;
typedef void snc_prv_t;
//snc Data Sturcture
typedef struct
{
uint16_t sncprot_id;
uint16_t sncprot_ref; //Refence Count
}snc_struct;
//Application Data
typedef struct
{
void *data;
size_t data_size;
}snc_appdata_t;
//Functions
//Null
bool snc_null(snc_struct *sncstruct);
//Reference Count
bool snc_retain(snc_struct *sncstruct);
void snc_release(snc_struct *sncstruct);
提前致谢。
几乎可以肯定是由于行中的错误分号
#define __SYNCROLOGY_VERSION_NUMBER__ 0.0.1;
而且,从不使用以两个下划线开头的宏。这是 C 中的未定义行为。修复该宏,并包含保护程序。
并且,从不 以 _t
结尾的变量,如果您的目标是 POSIX:它们也被保留。
这个定义
#define __SYNCROLOGY_VERSION_NUMBER__ 0.0.1;
错了,
首先不能有分号。其次,没有像 0.0.1
即使“#define SYNCROLOGY_VERSION_NUMBER 0.0.1;”这一行的分号是不必要的,它也不应该给出编译错误吧?
尝试在 snc_def.h 之前定义 inet.h ... :)
#include <arpa/inet.h>
#include "snc_def.h"