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 •°