Results 1 to 6 of 6

Thread: Inlining in GCC, code style/ design and Linux disassembler recommendations

  1. #1
    Member
    Join Date
    Jun 2009
    Location
    Kraków, Poland
    Posts
    1,474
    Thanks
    26
    Thanked 121 Times in 95 Posts

    Inlining in GCC, code style/ design and Linux disassembler recommendations

    1. First problem is that I want to mark functions to be inlined. My project consists of one .c file and few .h files, all of which are included (in)directly from that .c file. If I mark some function inline but not static then GCC's ld shows error "undefined reference". What does marking functions static do? Why I can't mark functions to be inlined in the same compilation unit?

    2. I've posted the zipped NetBeans project I've talked about above containing small framework for range coder based compressors. Feel free (or: I encourage you ; ) to make some comments about it.

    3. Please list your recommendations of Linux disassemblers which make a good use of debugging information (so I'll see original variable names in disassembled code).
    Attached Files Attached Files
    Last edited by Piotr Tarsa; 25th December 2011 at 05:02.

  2. #2
    Expert
    Matt Mahoney's Avatar
    Join Date
    May 2008
    Location
    Melbourne, Florida, USA
    Posts
    3,255
    Thanks
    306
    Thanked 779 Times in 486 Posts
    A static function means that the name is not exported, so you can't link to it from other files. Obviously if you link to a function, it's not inlined. If you want to inline a function, then declare it in the same file or a header file.

  3. #3
    Member
    Join Date
    Jun 2009
    Location
    Kraków, Poland
    Posts
    1,474
    Thanks
    26
    Thanked 121 Times in 95 Posts
    Well, as I said, there's only one .c file and few .h files. That produces single object file. I can't understand why GCC doesn't see inlined functions in such simple scenario.

  4. #4
    Administrator Shelwien's Avatar
    Join Date
    May 2008
    Location
    Kharkov, Ukraine
    Posts
    3,348
    Thanks
    212
    Thanked 1,012 Times in 537 Posts
    http://stackoverflow.com/questions/6...-useful-in-c99

    Also, with modern compilers only noinline directives seem to make any sense.
    Well, and also #define macros, because somehow even forceinline is frequently worse than a macro.

    > Linux disassemblers

    I don't use linux, but it'd be interesting if you could test http://out5.hex-rays.com/files/idademo_linux62.tgz
    Also, how about gcc -S ?

  5. #5
    Member
    Join Date
    Jun 2009
    Location
    Kraków, Poland
    Posts
    1,474
    Thanks
    26
    Thanked 121 Times in 95 Posts
    Inline static methods and objdump do the job. Thanks for suggestions.

  6. #6
    Administrator Shelwien's Avatar
    Join Date
    May 2008
    Location
    Kharkov, Ukraine
    Posts
    3,348
    Thanks
    212
    Thanked 1,012 Times in 537 Posts
    Well, I tried to suggest INLINE/NOINLINE from
    Code:
    #ifdef __GNUC__
     #define INLINE   __attribute__((always_inline)) 
     #define NOINLINE __attribute__((noinline))
     #define ALIGN(n) __attribute__((aligned(n)))
    #else
     #define INLINE   __declspec(forceinline)
     #define NOINLINE __declspec(noinline)
     #define ALIGN(n) __declspec(align(n))
    #endif
    Simple "inline" isn't guaranteed to inline anything, and the attribute might not have these side effects.

    In practice NOINLINE is the useful one, though, because at -O3 the compiler usually inlines all the functions
    anyway.

Similar Threads

  1. IntelC 11.1.065 vs gcc 4.5
    By Shelwien in forum The Off-Topic Lounge
    Replies: 35
    Last Post: 15th March 2011, 05:30
  2. GCC 4.6 faster than previous GCC, faster than LLVM
    By willvarfar in forum The Off-Topic Lounge
    Replies: 2
    Last Post: 15th November 2010, 16:09
  3. Good programming style & standards
    By encode in forum The Off-Topic Lounge
    Replies: 4
    Last Post: 29th July 2010, 12:00
  4. GCC 4.4.1 for Windows
    By Bulat Ziganshin in forum The Off-Topic Lounge
    Replies: 1
    Last Post: 16th January 2010, 00:39
  5. Design change
    By Skymmer in forum The Off-Topic Lounge
    Replies: 2
    Last Post: 16th November 2009, 18:02

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •