0

As I read here inline functions doesn't have to be inlined. So let's say we have code like this:

int a = 0;

inline void myFunc(){
    extern int a;
    a = 1;
}

int main(){
    int a = 0;
    myFunc();
}
  1. Does standard guarantee which a variable will be assigned 1?
  2. Are inline function compiled to a certain code before inlining? If so, what if I use register keyword for a in main?

EDIT: the global int a doesn't have to be declared in the same .c file

jbulatek
  • 154
  • 10

1 Answers1

1

Inlining a function does not introduce it into the caller's scope. Identifiers declared within a function (such as a in main in your example) are not visible from other functions.

So inline is irrelevant, and the top-level a is the one whose value is changed.

rici
  • 234,347
  • 28
  • 237
  • 341