0

I have a struct type defined in an header file myStruct.h as struct myStruct {...};.

Then I have declared one struct object in the main as:

myStruct s;

And once in a class header in the same way.

This doesn't work, giving an error:

`_ZN10myStructC2Ev' referenced in section `...myClass...' 
of.../module.pre.o: defined in discarded section 
`.text._ZN10myStructC2Ev[_ZN10myStructC5Ev]' of .../module.pre.o

If I only have the struct in the class it works, but I also need it in the main. How can I solve?

charles
  • 713
  • 1
  • 6
  • 16

1 Answers1

0

Define it as :

extern myStruct s;

in the header file.

AhmadWabbi
  • 2,253
  • 1
  • 20
  • 35