A
A
akaaxel2015-09-10 11:15:45
C++ / C#
akaaxel, 2015-09-10 11:15:45

How to hardcode variable values ​​in C at compile time?

For example, there is such code
int main()
{
//int a = ?
//int b = ?
asm("add r10, %0, %1", : :"r"(a), "r"(b));
return 0;
}
How to set variables a and b as numbers at compile time?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
akaaxel, 2015-09-10
@akaaxel

All found gcc -Da=10 -Db=12

D
Dmitry Kovalsky, 2015-09-10
@dmitryKovalskiy

Through preprocessor directives. #define and all that. And by the way, as far as I know, it's right to hardcode.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question