Can any one please let me know whether we can declare static variables inside an inline function and if we can how it is going to work between function calls.
Asked
Active
Viewed 1,461 times
-4
-
1You do it exactly the same way you do for non-inlined functions. Go give it a try. Don't worry, we'll wait. – Captain Obvlious Jul 10 '15 at 20:59
-
1@CaptainObvlious: Thanks. Please wait. – kadina Jul 10 '15 at 21:02
-
See here for example: http://stackoverflow.com/a/30557174/1413395 – πάντα ῥεῖ Jul 10 '15 at 21:03
1 Answers
1
Yes you can, and they should* behave exactly the same as for a non-inline static local.
* Visual Studio 6 (yes, that ancient compiler) has a bug where if the inline function gets both inlined and non-inlined in different translation units the local will get constructed twice.

Mark B
- 95,107
- 10
- 109
- 188
-
1Do people actually still care about compilers that are literally older than the language itself? – Baum mit Augen Jul 10 '15 at 21:09
-
@BaummitAugen: Evidently so. Also don't forget all 1.25 billion people in India are using a compiler that requires a DOS emulator to run.... – Lightness Races in Orbit Jul 10 '15 at 21:22