The standard doesn't impose any requirement to do this, but any sensible compiler will fold these constants down into one at compile-time. See e. G en.wikipedia.org/wiki/Constant_propagation.
The standard doesn't impose any requirement to do this, but any sensible compiler will fold these constants down into one at compile-time. See e.g. en.wikipedia.org/wiki/Constant_propagati... you're curious to know whether this has actually happened, you can always take a look at the assembler generated by the compiler.
The compiler should (but I believe in C is not required to) evaluate the constant expression at compile-time. A good compiler will almost certainly do it, though, when optimization is turned on.
If you want to avoid multiple evaluation, maybe just to speed up compilation and your constants fit into int, you could enforce single evaluation by using an enumeration constant, instead. Enum { cycles_per_period = PERIOD_IN_MS * CYCLES_PER_MS}.
It would eliminate the unnecessary creation of an enum. – oosterwal Feb 23 at 0:23 @oosterwal: If CYCLES_PER_PERIOD is a macro wouldn't it just be a substitution of PERIOD_IN_MS * CYCLES_PER_MS? Since the processor is oblivious to the semantics of C, it doesn't actually compute this value right?
The output from the preprocessor would be no different than the original scenario. – Oscar Korz Feb 23 at 1:27 @oosterwal: what do you mean by "creation of an enum"? An enum type and the corresponding constants are only an abstraction.
They don't result in any object being created or the symbol table being changed. – Jens Gustedt Feb 23 at 7:35 @okorz001, @Jens Gustedt: The problem with 'creating' CYCLES_PER_SECOND as an enum is that, in implementations that don't support long int enums, you are limited to int space. Therefore, if PERIOD_IN_MS * CYCLES_PER_MS exceeds the size of MAX_INT or if either of the previously defined macros represents a float value your results would be incorrect.
– oosterwal Feb 23 at 12:51 @oosterwal, indeed you are limited to int by the C99 standard. The constants forcibly have that type. Usually int is 32 bit so INT_MAX is fairly large.
– Jens Gustedt Feb 23 at 13:03.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.