So, I'm working on this scripting engine...
Now, here are a few classes I have; they're all defined in an overlaying Script class:
The problem is, when I do the following, I get two different numbers output - which sucks, since I'm using the udw_flag member to determine whether it's a class, variable, etc...Code:class Parser{ protected: // methods... }; class CppClass: public Parser{ private: class Operator{ private: unsigned int udw_return_flags; unsigned int udw_arg_flags; Script::Operator *pO_op; public: Operator(void); }; unsigned int udw_flags; String S_name; List<Script::CppBaseFunction> LtCBF_methods; List<Script::CppBaseFunction> LtCBF_statics; List<Script::CppClass::Operator> LtO_operators; List<Script::Variable> LtV_variables; // methods... protected: Script::Variable V_return; List<Script::Variable *> *pLtpV_args; List<Script::Variable> LtV_statics; Script *pS_engine; // methods... public: // methods... friend class Script; }; class Block{ protected: unsigned int udw_flags; Script::Clause *pC_parent; // methods... public: List<Script::Variable *> LtpV_variables; // methods... friend class Script; }; class Variable: public Script::Block{ private: Script::Block *pB_pointer; Script::Clause *pC_parent_real; Script::Class *pC_class; String S_name; double d_index; // methods... public: double d_number; String S_string; // methods... friend class CppClass; friend class Script; };
So, I take it the compiler rearranges the members and/or in some other way changes the footprint of the classes...Code:Script::Variable V_test; V_test.udw_flags = 777; // some random number Script::CppClass *pCC_test = (Script::Variable *)&V_test; printf("\nflags: %u", V_test.udw_flags); printf("\nflags: %u", pCC_test->udw_flags);
Can I prevent this with some command? (I'm using VC++ 7.0 by the way.)
Help, pretty please?



LinkBack URL
About LinkBacks


