Анонимный пространство имен и внешний вопрос "C".C++

Программы на C++. Форум разработчиков
Anonymous
Анонимный пространство имен и внешний вопрос "C".

Сообщение Anonymous »

My use-case is as follows for a project:

[*]A C header file with a few extern functions declared
[*]A C++ source file with those functions defined
[*]Compile the C++ source into a shared library
In a C source file use the functions declared in C header Связываясь против. Вещи начинают работать
с неназванным Namepsase. < /P>
Вот мой пример файла: < /p>

Код: Выделить всё

c_sample.h
:

Код: Выделить всё

#include "stddef.h"

extern void hello(void);
extern void bye(void);
< /code>
cpp_sample.cc
:

Код: Выделить всё

#include 
#include "c_sample.h"

extern "C" {
void hello(void) { std::cout 

Подробнее здесь: [url]https://stackoverflow.com/questions/79544030/anonymous-namespace-and-extern-c-linkage-question[/url]

Вернуться в «C++»