Unable to access struct static data members

Put problems with the Android NDK in this forum.

Unable to access struct static data members

Postby agsalcedo » Thu Sep 22, 2011 6:58 pm

Hello, I'm having the next kind of error when linking the application:

undefined reference to 'MyStructure::K_VARIABLE_A

The structure is defined inside "MyStructure.h" as:

[code]struct MyStructure
{
const static int K_VARIABLE_A=1;
const static int K_VARIABLE_B=2;
...
};
[\code]

So my question is: Why I can't access static members from structures or classes using android NDK?. My source code compiles successfully for Windows platform but I get the error mentioned above when compiling for the android platform.

Thanks in advance.
Last edited by agsalcedo on Fri Sep 23, 2011 12:46 am, edited 1 time in total.
agsalcedo
Freshman
Freshman
 
Posts: 2
Joined: Thu Sep 15, 2011 6:13 pm
Location: Mexicali, Baja California, Mexico

Top

Re: Unable to access struct static data members

Postby jonbonazza » Thu Sep 22, 2011 10:18 pm

You need a ';' after the '}'
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Re: Unable to access struct static data members

Postby agsalcedo » Fri Sep 23, 2011 12:47 am

I found my answer posting my question in stackoverflow.com, http://stackoverflow.com/q/7519404/959741

Thanks anyway.
agsalcedo
Freshman
Freshman
 
Posts: 2
Joined: Thu Sep 15, 2011 6:13 pm
Location: Mexicali, Baja California, Mexico

Re: Unable to access struct static data members

Postby jonbonazza » Fri Sep 23, 2011 4:49 pm

Furthermore, You shouldn't really be using a struct in this case in teh first place. Simply using an enum type would be the best. Wrapping an enum in a struct is unneccessary.
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Top

Return to NDK Problems

Who is online

Users browsing this forum: No registered users and 3 guests