linth / learn-cpp

learn c++ by examples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

learn-cpp

learn c++ by examples

C code 提供給 C++ 使用

void c_function() {
  /** do something. */
  // ...
}

extern "C" {

  /* C code */
  #include "xxx/xx/xxx.h"

  void c_function();
}

int main() {
  c_function();
  return 0;
}
$ g++ -c main.cpp
$ g++ main.o cfunc.o -o a.out
$ ./a.out

C++ code 提供給 C 使用

/* c_function.h */

#ifdef __cplusplus
extern "C" {
#endif

void c_function();

#ifdef __cplusplus
}
#endif

Reference

About

learn c++ by examples


Languages

Language:C++ 74.1%Language:C 25.9%