作者SweepingMonk ((((((((((()))))))))))
看板EE_DSnP
标题Re: [问题] 关於 C & C++ 之间的呼叫
时间Mon May 26 17:10:22 2008
我尝试自己写一些简单的程式测试看看
结果越弄越糊涂了
以下是我写的code
(本来认为会出错,结果可以compile过,也可以执行)
(含 Makefile 共 4 个档案:myCppCode.h, myCppCode.cpp, test.c)
myCppCode.h
------------------------------------------------
#ifndef MY_CPP_CODE_H
#define MY_CPP_CODE_H
#endif
void f(int i);
------------------------------------------------
myCppCode.cpp
------------------------------------------------
#include "myCppCode.h"
#include <iostream>
using namespace std;
void f(int i){ cout << "num is " << i << endl; }
-------------------------------------------------
test.c
-------------------------------------------------
#include "myCppCode.h"
int main(){
f(1);
return 0;
}
-------------------------------------------------
Makefile
-------------------------------------------------
all: result
result:myCppCode.o test.o
g++ myCppCode.o test.o -o test
myCppCode.o:
g++ -c myCppCode.cpp
test.o:
g++ -c test.c
-------------------------------------------------
好像完全不需要特别处理
这是怎麽回事呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.4.234
※ 编辑: SweepingMonk 来自: 140.112.4.234 (05/26 17:12)
※ 编辑: SweepingMonk 来自: 140.112.4.234 (05/26 17:14)
1F:推 ric2k1:是的, C file 用 g++ compile 是可以呼叫 C++ 05/26 21:10
2F:→ ric2k1:所以问题是, AIGER 的 files 可以用 g++ 来 compile 吗? 05/26 21:10
3F:→ SweepingMonk:谢谢老师 我再试试看 05/26 21:18
4F:推 BVB:这篇很有参考价值=w=b 05/28 17:26