In C, what does “public” mean when put before a global variable?

后端 未结 4 1342
[愿得一人]
[愿得一人] 2021-01-13 12:38

I\'m going through the source code of the \"less\" unix tool by Mark Nudelman, and the beginning of main.c has many of the following:

public int  logfile = -         


        
4条回答
  •  爱一瞬间的悲伤
    2021-01-13 13:07

    In the file less.h is your answer:

    #define public      /* PUBLIC FUNCTION */
    

    It seems like public is only used as a marker for public/global functions and variables. When compiled, it is expanded to nothing.

    How to find this information?

    1. Search the .c file from top to the location of the identifier you want more information about
    2. If you do not find any declaration, look for #include directives
    3. Open any included file and look for the declaration of what you are looking for
    4. Repeat from step two for every included file

    In this case, that was pretty simple.

提交回复
热议问题