I will have hundreds of functions such as this
void OrganOut()
{
Title("OrganOut");
Where the first line puts the title of the function up on the LCD display (it's an embedded music system as you can probably guess by the name). As the function name is obviously known at compile time, is there any way to automate placing the name in Title to avoid entering the name twice ?
In computing, compile-time function execution (or compile time function evaluation, or general constant expressions) is the ability of a compiler, that would normally compile a function to machine code and execute it at run time, to execute the function at compile time.
The time () function is defined in time.h (ctime in C++) header file. This function returns the time since 00:00:00 UTC, January 1, 1970 (Unix timestamp) in seconds. If second is not a null pointer, the returned value is also stored in the object pointed to by second.
In such case, you should declare the function at the top of the file calling the function. While creating a C function, you give a definition of what the function has to do. To use a function, you will have to call that function to perform the defined task. When a program calls a function, the program control is transferred to the called function.
In Configuration Properties > C/C++ > Precompiled headers, set Precompiled Headers to: "Not using Precompiled Headers" In the same C/C++ branch, go to Advanced, change Compile As to: "Compile as C code (/TC)"
Every C program has at least one function, which is main (), and all the most trivial programs can define additional functions. You can divide up your code into separate functions.
You are looking for __func__
.
void OrganOut()
{
Title(__func__);
}
This feature is available from the C99 and C++11 standards respectively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With