so have serveal c++ files , need call c function after c++ part of program done. if there way somehow magically "start c file" (i hope know mean) glad hear too. actual problem: i'm trying call c function @ end of main function in main c++ file. saw of call c function c++ code , tried correct way, header file c file looks kind of this:
#ifndef h_file #define h_file #ifdef __cplusplus extern "c" { #endif void foo(); void bar(); #ifdef __cplusplus } #endif
i tried include header file in c++ file this:
extern "c" { #include "folder/file.h" }
i alternatively tried basic #include "folder/file.h"
but i'm getting undefined reference error when i'm trying use foo() function c file. .pro file looks kind of this:
qt += core gui greaterthan(qt_major_version, 4): qt += widgets target = example template = app qmake_cxxflags += -std=c++11 sources += main.cpp\ folder/file.c \ headers += main.h \
so guess have add kind of flag compiled correctly, missing? thank help!
you may missing 1 more #endif @ end of header file
Comments
Post a Comment