2011-05-16 22 views
-1

我知道標題是某種愚蠢的,但我不知道如何問別人。 我試圖在我的頭文件(head.h)中包含標準庫(stdio.hstring.h)之一,然後將其包含在我的main.c腳本中。我的Windows 7 x64 TCC(http://bellard.org/tcc/),但學院的solaris(我不知道,但它是嚴重的石塊的東西)一切工作正常gcc 4.0.2(2005年顯然)只是不這樣做...(我得到「未定義的符號」 錯誤等)ANSI C兩級包括

main.c中(節選):

#include "head.h" 

head.h(節選):

// include librarys 
#include <stdio.h>  // standard input/output 
#include <string.h>  // operations on strings 
#include <locale.h>  // unicode string output 

生成文件(完整):

CX = tcc 
IN = funcdef.o main.o 

outfile: ${IN} 
${CX} -o outfile.out ${IN} 

funcdef.o: head.h funcdef.c 
main.o: head.h main.c 

我在做什麼錯?當TCC不是時,爲什麼GCC的行動遲緩?D? 在此先感謝您的答案!

+2

你會得到什麼錯誤? – 2011-05-16 15:11:48

+1

你收到什麼錯誤信息?請逐字逐句。 – 2011-05-16 15:11:56

+3

「未定義符號」是一個鏈接器錯誤,不是編譯器錯誤。可能與'#include'無關(或者不多)。請張貼您在Solaris上使用的任何內容 - 您使用tcc進行的工作是無關緊要的。 – Mat 2011-05-16 15:12:24

回答

0

問題是funcdef.c中有幾個語法錯誤,導致它沒有將其與main.c鏈接。

而語法錯誤主要是ANSI C中的C++代碼,它被tcc所容忍,並被gcc所憎恨。 ^^