Search code examples
gccgcc-warning

C / GCC - What does 'at top level' refer to?


This feels stupid to ask but I don't know the answer.

I've tried googling what I wrote as the question but nothing I answered my question. I also tried searching StackOverflow specifically as well.

When compiling code with gcc –Wall.

What does the 'At top level' refer to :

exam06.c: At top level:

Solution

  • In the global scope, i.e. not in any other scope, such as a structure definition, function implementation, etc.

    int globalInt = 0; // <--- at the "top level"
    
    void someFunction() { // <--- at the "top level"
        int localInt = 0; // <--- in the function's scope
    }