This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Placing C++ member functions at specific region

Is there a way to specify that all member functions for a class or template are placed in a specific region? Specifying a section for each member function works, but makes maintenance of large classes more tedious. Ideally there should be a way to do this for all functions in a class or template. In the example below square() is placed in "sram2" but cube() is not. Thanks.

#pragma arm section code = "sram2"
class foo
{
public:
    int __attribute__((section("sram2"))) square(int x) { return x * x; }
    int cube(int x) { return x * x * x; }
};
#pragma arm section code

Parents
  • Thanks for your responses.

    Implementing a member function within the class declaration does not necessarily make it inline. The ARM compiler appears to use a similar criteria for inlining member functions than for inlining standalone functions. Member functions can be placed in a specific section using __attribute__((section())), as is the case of foo::square() in the example. Specifying a section overrides the compiler's inlining criteria, e.g. the function will not be inlined if the caller is in a different section. It would be desirable to have a directive to place all members functions of a class in the same section, but apparently there is none.

Reply
  • Thanks for your responses.

    Implementing a member function within the class declaration does not necessarily make it inline. The ARM compiler appears to use a similar criteria for inlining member functions than for inlining standalone functions. Member functions can be placed in a specific section using __attribute__((section())), as is the case of foo::square() in the example. Specifying a section overrides the compiler's inlining criteria, e.g. the function will not be inlined if the caller is in a different section. It would be desirable to have a directive to place all members functions of a class in the same section, but apparently there is none.

Children
No data