The problem with * is that you don't know what files
are necessary, and adding many #ifdefs SAMPLE_UNITTEST
is a lot of work. Also it is intrusive. The pragma source
can be intrusive or not. In the other words, if you have
an existing library someone can generate the file that
represents the source for that library in a way the orignal
library don´t need to be changed. But if it is something standard
would be nice to have it for all libraries. This is also something
that will not broke old compilers.
> > This solution does not scale
> > and don't compose well compared with this pragma source.
>
> The pragma source proposal has its charm, but there is a slight problem
> in that it does not exist. I also suspect that it would overlap or
> conflict with the upcoming C++ modules feature.
C++ modules feature is similar of binary libs. You need to compile
for each platform. Macros are also not available at the same form,
and it will not be compatible with C.
> And it also don't scale
> in the sense that pretty often the source code needs some special
> compiler flags, prebuild and postbuild steps, etc, which might depend on
> the platform, configuration, etc.
Please note that this feature is not a build system and it doesn't
replace build systems. This has been a source of confusion. The
name of the feature could be "new pragmas" to avoid confusion.
We can have specific platform settings. I also would like to have
compiler setting inside the source. Something similar of what VC++ has
for warnings
#pragma warning( push )
#pragma warning( disable : 4705 )
#pragma warning( disable : 4706 )
#pragma warning( disable : 4707 )
// Some code
#pragma warning( pop )
Some of the compiler flags could be universal, but this
is not necessary. If the compiler had this setting on the source
the proposed feature could be used together with #ifdef for
an specific compiler.
The way it is today, when you specify compiler settings it will be
applied for all sources.
>You cannot replace the myriad of the
> existing build systems with a single pragma.
>
> In simpler cases it would work though.
Usually my build is for windows, and I have to sign the executable,
generate documentation, tests, run the installer program,sign the installer
and publish. Also I have to do some parts on different computers (mac).
This feature will not replace this build.