在C中创建头文件

时间:2014-05-10 15:06:03

标签: c header-files

我在我的主要类client.c中包含了C类。

#include "asn_application.h"
#include "asn_codecs_prim.h"
#include "asn_codecs.h"
#include "asn_internal.h"
#include "asn_system.h"
#include....

编译时我有这个错误

Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/BIT_STRING.d" \
    -MT"src/BIT_STRING.d" -o "src/BIT_STRING.o" "../src/BIT_STRING.c"
../src/BIT_STRING.c:5:26: warning: asn_internal.h: No such file or directory
../src/BIT_STRING.c:6:24: warning: BIT_STRING.h: No such file or directory
../src/BIT_STRING.c:12: error: expected '=', ',', ';', 'asm' or
'__attribute__' before 'asn_DEF_BIT_STRING_tags'
../src/BIT_STRING.c:15: error: expected '=', ',', ';', 'asm' or
'__attribute__' before 'asn_DEF_BIT_STRING_specs'
../src/BIT_STRING.c:20: error: expected '=', ',', ';', 'asm' or
'__attribute__' before 'asn_DEF_BIT_STRING'
../src/BIT_STRING.c:48: error: expected ')' before '*' token
../src/BIT_STRING.c:76: error: expected '=', ',', ';', 'asm' or
'__attribute__' before 'BIT_STRING_encode_xer'
../src/BIT_STRING.c:141: error: expected ')' before '*' token
make: *** [src/BIT_STRING.o] Error 1

它说asn_internal.hBIT_STRING.h ...不存在,但文件在那里。也许是因为我没有头文件? 我尝试创建client.h

#ifndef client
#define client
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <stdlib.h>

#include "asn_application.h"
#include "asn_codecs_prim.h"
#include "asn_codecs.h"
#include "asn_internal.h"
#include "asn_system.h"
#include "ber_decoder.h"
#include "ber_tlv_length.h"
#include "ber_tlv_tag.h"
#include "BIT_STRING.h"
#include "BOOLEAN.h"
#include "constr_SEQUENCE.h"
#include "constr_TYPE.h"
#include "constraints.h"
#include "der_encoder.h"
#include "INTEGER.h"
#include "Message01.h"
#include "Message02.h"
#include "Message03.h"
#include "Message02.h"
#include "Message04.h"
#include "NativeEnumerated.h"
#include "NativeInteger.h"
#include "OCTET_STRING.h"
#include "per_decoder.h"
#include "per_encoder.h"
#include "per_opentype.h"
#include "per_support.h"
#include "PrintableString.h"
#include "xer_decoder.h"
#include "xer_encoder.h"
#include "xer_support.h"

#endif

但它没有解决问题。我该怎么办?

1 个答案:

答案 0 :(得分:-1)

您需要将目录添加到包含路径

请参阅手册页http://linux.die.net/man/1/gcc

注意-I标志

可能需要考虑-L标志和-l标志