How to always compile a cpp file using Eclipse?

I included the unix timestamp __DATE__in one of the cpp source files to indicate the build date of my program. Naturally, with default settings, it compiles the file only when I change it, but now I want it to always be compiled. I tried to search for project parameters, but it seems that this will require a deeper understanding of the compiler. I am using Eclipse with g ++.

I tried to search Google and find the answer, but it was difficult for me to find good keywords for this.

There is also a noticeable difference, am I making this change for the header file instead of the original file?

Thanks for answers.

+1
source share
2 answers

'pre-build', touch ( ).

+2

, .

, .

. date.cpp :

#include <string>

std::string build_time() {
    return __DATE__ " " __TIME__;
}

cout << "Built on " << build_time() << endl;

, ( ). date.cpp, . ,

a > C/++ Build > > >

comand Linux:

rm -f <path to the Debug / Release directory>/date.o

<path to the Debug / Release directory>.

Windows del /q, , , rm -f, , .

date.o, , .

, , , , .

+1

Source: https://habr.com/ru/post/1690848/


All Articles