There is my question, Let's say I got a fonction which takes a numeric
argument long enough so that there has to be spaces in it to represent
it correctly. (Ex. 0xf63a002c5ff0338ec becoming -> 0xf63a 002c 5ff0
338ec) is there a way to tell the preprocessor to make:
fct(0xf63a 002c 5ff0 338ec) into ===> fct(0xf63a) f(002c)
(5ff0) (338ec) (exactly as this without the "0x" before the three
lastest forms.
I examined Ben Pfaff's reply. Let me give you more perspective.
There are a LOT of things that the C preprocessor won't do. Here are two
examples from microcontroller work:
#1: It is sometimes desirable to calculate a numerator and denominator so
that a given real number can be approximated by a single integer
multipication followed by a single integer division. For an inexpensive
microcontroller, it might be desirable to put into the source code a real
number (3.141592654, for example) and have this used in the code as the
numerator and denominator of the best rational approximation with numerator
and denominator not exceeding 255. (This approximation is 245/78, by the
way, and can be found by a continued fraction algorithm.) The C
preprocessor can't make the mapping from (3.141592654, 255, 255) to
(245,78).
#2: Software timers are often grouped together in microcontroller work for
efficiency (a timer as I'm using it here is a byte which is periodically
decremented, but not below zero). The preprocessor can't "collect and
combine" timer definitions.
There are a lot of approaches to "escape from" the C preprocessor. People
often use scripting languages or generalize the build process to include
source code which is "decorated" with constructs which are filled-in by
another tool which can make sophisticated mappings beyond the capabilities
of the 'C' preprocessor.
You are not the first to notice that the C preprocessor is simplistic.
People usually write their own tools and introduce another phase or two to
compilation.