Predefined Macros - C Preprocessor

C examples for Preprocessor:Macro

Introduction

The standard macros are listed in the following table.

Directive Description
__FILE__ The name and path for the current file.
__LINE__ The current line number.
__DATE__ The compilation date in MM DD YYYY format.
__TIME__ This compilation time in HH:MM:SS format.
__func__ The name of the current function. Added in C99.
__STDC__ Defined as 1 if the compiler complies with the ANSI C standard.

Predefined macros provides debugging information.

The following error message includes the file name and line number where the message occurs.

Demo Code

#include <stdio.h>
int main(void) {

   printf("Error in %s at line %d", __FILE__, __LINE__);
}

Result


Related Tutorials