Advertisement

Function inlining

Started by July 13, 2000 06:56 PM
1 comment, last by Desmond 24 years, 5 months ago
I made this part of code and I just wanted to know if it is allright... It''s concerning C++ function inlining... In my DATA.H file I got this code: // DATA.H inline void requestData(void); And in my DATA.CPP file I got this // DATA.CPP extern void requestData(void) { // My code goes here } if I use the function requestData in another file now will it be treated as inline even if the body of the function is not in the header file?
I think you should put "extern inline void requestData(void)" in the cpp file.
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Advertisement
No, this won''t work without a global optimizer that is applied at the linking stage. The Intel compiler has one, but I''m not sure whether you can force it to inline functions. With most compilers (including VectorC, GNU C/C++ and Visual C/C++) you need to put the definition of your inline function in the header file.


Andrew Richards
CodePlay - http://www.codeplay.com
Andrew RichardsCodePlay - http://www.codeplay.com

This topic is closed to new replies.

Advertisement