C++ Logo

std-proposals

Advanced search

[std-proposals] Preprocessor

From: BAMBYK <uravasinski_at_[hidden]>
Date: Mon, 14 Aug 2023 07:57:40 +0300
We often surround out code into separated folders. And we always must write
the path to the folder before a file we want to include. You may use -I
flag but it is not clearly comfortable. This feature would lead to better
code structure and faster include.


#go "output"
    // output
    #include "helloWorld.h"
    #go "messages"
        // output/messages
        #include "messageData1.h"
        #include "messageData2.h"
    #exit
#exit


In this example #go means set folder the files are included from. The
compiler simply adds "path + '/' before each include. The #exit quit from
previous #go block.
These keywords can be nested the same as directories. So the nested #go
affect each other. It does not affect at anything else.


Of course any path can be specified:

#go "output/messages"
    #include "messageData1.h"
    // ...
#exit


if the directory has only alphanumeric characters it can be used without
quotes.

#go output
    // ...
#exit

Received on 2023-08-14 04:57:53