C's Predefined Macros


A list of predefined macros (__FILE__, __LINE__, __STDC__...) with description and an example of how to use them.

__FILE__ - a string that holds the path/name of the compiled file;
__LINE__ - an integer that holds the number of the current line number;
__DATE__ - a string that holds the current system date;
__TIME__ - a string that holds the current system time;
__STDC__ - defined as the value '1' if the compiler conforms with the ANSI C standard;
__cplusplus - determines if your compiler is in C or C++ mode. Usually used in headers.


#include <stdio.h>
void main(void)
{
    printf("The path/name of this file is %s/n", __FILE__);
    printf("The current line is %d/n", __LINE__);
    printf("The current system date is %s/n", __DATE__);
    printf("The current system time is %s/n", __TIME__);
    #ifdef __STDC__
        printf("The compiler conforms with the ANSI C standard/n");
    #else
        printf("The compiler doesn&apos;t conform with the ANSI C standard/n");
    #endif
    #ifdef __cplusplus
        printf("The compiler is working with C++/n");
    #else
        printf("The compiler is working with C/n");
    #endif
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值