I have started learning C++. i came across one of the use case like below but could not explore it more. please let me know your views.
extern "C" {
#include "file1.h"
#include "file2.h"
}
I have started learning C++. i came across one of the use case like below but could not explore it more. please let me know your views.
extern "C" {
#include "file1.h"
#include "file2.h"
}
First you should kown what is function overloading in c++ which is not in existence in c.
In order to support function overloading,
c++ compiler need to translate functions with the same name but different function signature into different symbol names.
However, you may invoke some libs written by c++ in a c program.But because of the different function name translation mechanism,there will be some error when invoking c++-style functions in a c program.
So, the extern c
means i want the c++ compiler translate the function name like the c complier does.Thus it's ok to invoke c++ libs in your c program.