[Qt-interest] C code in QT use queue in Class
Pavel Koshevoy
pavel at aragog.com
Tue Aug 4 19:54:24 CEST 2009
Mic J wrote:
>> You should be able to use any C code with C++ (nothing to do with Qt
>> really).
>>
>
> Well the C code works flawlessly.
> but when i try to use it with C++ (in a QT class)
> It complains of multiple defined instances ot the variables.
>
> if i look at it with nm compiled with C the global variables
> are of type C for common varables.
> When compiled in QTCreator (C++ compiler (G++)).
> They are of type B "uninitialized" BSS section.
> And then they clash.
>
> i played around with extern i tried using this apporach.
> http://www.learncpp.com/cpp-tutorial/42-global-variables/
> Using header for extern vars (declaration) and cpp file for
> definition. and a couple of other appraches. all this however
> touches the C code. and i really don't want to mess with it.
>
>
We still need to see some code. Show us the header file you are
including. Global variables and extern declarations have been around
for a while. Perhaps you don't need to include the header at all (in
the C++ header), but instead make an extern "C" declaration for the
variable that you need from the C header.
Pavel.
PS. When you referred to TAILQ earlier, I assume you mean the queue
macros described by man 3 queue (#include <sys/queue.h>). It's the
first time I've heard of TAILQ.
More information about the Qt-interest-old
mailing list