Search Results

Search found 2 results on 1 pages for 'user176168'.

Page 1/1 | 1 

  • gcc -finline-functions behaviour?

    - by user176168
    I'm using gcc with the -finline-functions optimization for release builds. In order to combat code bloat because I work on an embedded system I want to say don't inline particular functions. The obvious way to do this would be through function attributes ie attribute(noinline). The problem is this doesn't seem to work when I switch on the global -finline-functions optimisation which is part of the -O3 switch. It also has something to do with it being templated as a non templated version of the same function doesn't get inlined which is as expected. Has anybody any idea of how to control inlining when this global switch is on? Here's the code: #include <cstdlib> #include <iostream> using namespace std; class Base { public: template<typename _Type_> static _Type_ fooT( _Type_ x, _Type_ y ) __attribute__ (( noinline )); }; template<typename _Type_> _Type_ Base::fooT( _Type_ x, _Type_ y ) { asm(""); return x + y; } int main(int argc, char *argv[]) { int test = Base::fooT( 1, 2 ); printf( "test = %d\n", test ); system("PAUSE"); return EXIT_SUCCESS; }

    Read the article

  • Is there a way to find out whether a class is a direct base of another class?

    - by user176168
    Hi I'm wondering whether there is a way to find out whether a class is a direct base of another class i.e. in boost type trait terms a is_direct_base_of function. As far as I can see boost doesn't see to support this kind of functionality which leads me to think that its impossible with the current C++ standard. The reason I want it is to do some validation checking on two macro's that are used for a reflection system to specify that one class is derived from another e.g. header.h: #define BASE A #define DERIVED B class A {}; class B : public A { #include <rtti.h> }; rtti.h: // I want to check that the two macro's are correct with a compile time assert Rtti<BASE, DERIVED> m_rtti; Although the macro's seem unnecessary in this simple example in my real world scenario rtti.h is a lot more complex. One possible avenue would be to compare the size of the this pointer with the size of a this pointer cast to the base type and some how trying to figure out whether its the size of the base class itself away or something (yeah your right I don't know how that would work either! lol)

    Read the article

1