verify inline function

Discussion in 'C++' started by mashrur.mia@gmail.com, May 29, 2006.

  1. Guest

    Hello All,

    Since "inline" keyboard is basically an advice to the compiler to
    inline a function, is there a way to know whether the complier took the
    advice?

    I guess one way to verify is to check the file size of the executable
    or the object file. Is there any other way? Perhaps checking the
    assembler code the compiler generates? I am using g++ so I can
    generated .s file with -S option. Although, I am not a assember
    programmer, but even when simple inline function is used, I see the
    assember using "call" instruction for my simple inline function.

    Any help will be appreciated.

    Mashrur
    , May 29, 2006
    #1
    1. Advertising

  2. Achintya Guest

    wrote:
    > Hello All,
    >
    > Since "inline" keyboard is basically an advice to the compiler to
    > inline a function, is there a way to know whether the complier took the
    > advice?
    >
    > I guess one way to verify is to check the file size of the executable
    > or the object file. Is there any other way? Perhaps checking the
    > assembler code the compiler generates? I am using g++ so I can
    > generated .s file with -S option. Although, I am not a assember
    > programmer, but even when simple inline function is used, I see the
    > assember using "call" instruction for my simple inline function.
    >
    > Any help will be appreciated.
    >
    > Mashrur


    You need to look into different g++ compier options. I'm sure which one
    to use specifically.

    -vs_p
    Achintya, May 29, 2006
    #2
    1. Advertising

  3. * :
    >
    > Since "inline" keyboard is basically an advice to the compiler to
    > inline a function,


    Sorry, no, it's not.

    It's tells the compiler that you're taking responsibility for having all
    definitions of that function identical, so that the linker can choose
    one, instead of complaining about multiple definitions.

    Additionally it serves as hint about inlining, which however your
    compiler is likely to ignore, given that the primary usage is in direct
    conflict with the hinting.


    > is there a way to know whether the complier took the advice?


    For any particular call of the function you can check the machine code.

    However, if you're concerned about execution time or memory usage you
    should measure: nothing else is good enough.

    One way to measure is to use a profiler tool.


    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, May 29, 2006
    #3
  4. Guest

    I think I found it, its optimizer option -O3
    , May 29, 2006
    #4
  5. Hello,

    wrote:

    > Since "inline" keyboard is basically an advice to the compiler to
    > inline a function, is there a way to know whether the complier took
    > the advice?
    >
    > I guess one way to verify is to check the file size of the executable
    > or the object file. Is there any other way? Perhaps checking the
    > assembler code the compiler generates? I am using g++ so I can
    > generated .s file with -S option. Although, I am not a assember
    > programmer, but even when simple inline function is used, I see the
    > assember using "call" instruction for my simple inline function.
    >
    > Any help will be appreciated.


    Post a minimal example of code and the commands to reproduce the
    problem. Since it has to do with the quality of a single compiler, i.e.
    it is rather off-topic here, better post your question to a group
    dedicated to that, e.g. gnu.g++.help. Perhaps read about doing
    bug-reports for gcc first, and include information in your post
    accordingly.

    Bernd Strieder
    Bernd Strieder, May 29, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Abhi
    Replies:
    2
    Views:
    725
    E. Robert Tisdale
    Jul 3, 2003
  2. Nish
    Replies:
    4
    Views:
    479
    Thomas Stegen
    Oct 8, 2004
  3. TGOS
    Replies:
    3
    Views:
    366
    Kevin Bracey
    Feb 28, 2005
  4. Ajay
    Replies:
    5
    Views:
    372
    Pete Becker
    Apr 1, 2006
  5. Replies:
    7
    Views:
    426
Loading...

Share This Page