find c files within c++ project

A

ahso

Hi
I get tons of: undefined references so i suspect to have
some c header files which need: extern "C"
So how can I find those? Or can i put this in every header?
Thanks
 
M

Marcel Müller

I get tons of: undefined references so i suspect to have
some c header files which need: extern "C"

Are you sure?
So how can I find those? Or can i put this in every header?
Thanks

Tracking a few examples of your undefined symbols to their root will be
more helpful than firing haphazardly with the shotgun on header files.

The extern "C" C++ guards are useful if and only if C code sould be used
within C++ code.


Marcel
 
J

Jorgen Grahn

Hi
I get tons of: undefined references so i suspect to have
some c header files which need: extern "C"
So how can I find those?

They are only C header files if their implementation is compiled
as C code rather than C++. Surely your Makefile (or whatever you use
for a build system) can tell you what it compiles and how.

/Jorgen
 
A

ahso

LIBS += -llua -lBulletDynamics -lBulletCollision -lLinearMath -
lcurl -lopenal -lalut

Those are the Qtcreator libs. ~400 undefined references errors so
something very basic is very wrong.
Nobody can help how to approach such?
 
N

Nobody

I get tons of: undefined references so i suspect to have
some c header files which need: extern "C"
So how can I find those? Or can i put this in every header?

If you're including C headers which don't have the C++ "guards", then you
can do:

extern "C" {
#include <foo.h>
}

This usually works, but there are things which can appear in a C header
which make it invalid as C++ (e.g. use of C++-specific keywords as
identifiers).
 
J

Juha Nieminen

Nobody said:
If you're including C headers which don't have the C++ "guards", then you
can do:

extern "C" {
#include <foo.h>
}

That's such a "Paulish" answer that I'm pretty sure you are him.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top