понедельник, 2 февраля 2015 г.

Совмещение C и C++ кода

Понадобилось в одном проекте совместить C и C++ . Чтобы не забыть:

Файл test.cpp
#include <iostream>
extern "C" int cpp_function()
{
std::cout <<"C++ function...\n";
return 0;
}


Файл test.h
extern int cpp_function();

Файл  main.c
#include <stdio.h>
#include <test.h>
int main(int argc, char **argv)
{
cpp_function();
}