Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22233

Where should function attributes go?

$
0
0

Suppose I want to mark a non-inline function with [[gnu::cold]]; should the attribute be placed in the declaration in the header, or should it go with the definition in a source file? Assume that I will not be using LTO and simply want that specific function to be optimized for binary size and not execution speed.

header example:

[[gnu::cold]] void rarely_called_func();

source file example:

[[gnu::cold]] void rarely_called_func() { ... }

Also, which position in the declaration/definition should it be:

/* A */ int /* B */ func () /* C */;

Viewing all articles
Browse latest Browse all 22233

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>