Predefined names

The following names are predefined within the preprocessor:

_LINE_ : The current source file line number, a decimal integer constant.

_FILE_ : The ‘name’ of the current source code file, a string literal.

_DATE_ : The current date, a string literal. The form is Apr 21 1990, where the month name is as defined in the library function asctime & the first digit of the date is a space if the date is less than 10.

_TIME_ : The time of the translation; again a string literal in the form produced by asctime, which has the form “hh:mm:ss”.

_STDC_ : The integer constant 1. This is used to test if the compiler is standard-conforming, the intention being that it will have different values for different releases of the standard.


The standard specifies that any other reserved names will either start with an underscore followed by an uppercase letter or another underscore, so you know that you are free to use any other names for your own purposes.


#line

This is used to set the value of the built in names _LINE_ and _FILE_. Why do this?

Because a lot of tools now a days actually generate C as their output. This directive allows them to control the current line number. It is of very limited interest to the ‘ordinary’ C programmer.

Its form is
# line number optional-string-literal newline

The number sets the value of _LINE_, the string literal, if present, sets the value of _FILE_.

In fact, the sequence of tokens following #line will be macro expanded. After expansion, they are expected to provide a valid directive of the right form.



About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





 Previous