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

ஜி.சி.சி
விரைவான அட்டவணைகள்