Код: Выделить всё
main.ccКод: Выделить всё
extern "C" {
#include "single_header.h"
}
int main() {}
Код: Выделить всё
single_header.hКод: Выделить всё
#include
void f() {
int *p = malloc(sizeof(int));
free(p);
}
Код: Выделить всё
$ g++ main.cc
In file included from main.cc:2:
single_header.h: In function ‘void f()’:
single_header.h:3:18: error: invalid conversion from ‘void*’ to ‘int*’ [-fpermissive]
3 | int *p = malloc(sizeof(int));
| ~~~~~~^~~~~~~~~~~~~
| |
| void*
Подробнее здесь: https://stackoverflow.com/questions/783 ... brary-in-c
Мобильная версия