gcc -D ਵਿਕਲਪ ਫਲੈਗ

gcc -D ਪ੍ਰੀਪ੍ਰੋਸੈਸਰ ਦੁਆਰਾ ਵਰਤੇ ਜਾਣ ਵਾਲੇ ਮੈਕਰੋ ਨੂੰ ਪਰਿਭਾਸ਼ਿਤ ਕਰਦਾ ਹੈ।

ਸੰਟੈਕਸ

$ gcc -Dname [options] [source files] [-o output file]
$ gcc -Dname=definition [options] [source files] [-o output file]

ਉਦਾਹਰਨ

ਸਰੋਤ ਫਾਈਲ myfile.c ਲਿਖੋ :

// myfile.c
#include <stdio.h>
 
void main()
{
    #ifdef DEBUG   
       printf("Debug run\n");
    #else
       printf("Release run\n");
    #endif
}

 

myfile.c ਬਣਾਓ ਅਤੇ ਇਸਨੂੰ ਪਰਿਭਾਸ਼ਿਤ DEBUG ਨਾਲ ਚਲਾਓ:

$ gcc -D DEBUG myfile.c -o myfile
$ ./myfile
Debug run
$

 

ਜਾਂ myfile.c ਬਣਾਓ ਅਤੇ ਇਸਨੂੰ ਬਿਨਾਂ DEBUG ਪਰਿਭਾਸ਼ਿਤ ਕੀਤੇ ਚਲਾਓ:

$ gcc myfile.c -o myfile
$ ./myfile
Release run
$

 


ਇਹ ਵੀ ਵੇਖੋ

Advertising

ਜੀ.ਸੀ.ਸੀ
°• CmtoInchesConvert.com •°