Content deleted Content added
No edit summary |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 14:
}}</ref>
The [[C Sharp (programming language)|C#]] programming language also allows for directives,
The [[Haskell]] programming language also allows the usage of the C preprocessor.
Line 133:
==== Binary resource inclusion ====
[[C23 (C standard revision)|C23]] and [[C++26]] introduce the <code>#embed</code> directive for '''binary resource inclusion''' which allows including the content of a binary file into a source even
This allows binary resources (like images) to be included into a program without requiring processing by external tools like <code>xxd -i</code> and without the use of [[string literal]]s which have a length limit on [[MSVC]]. Similarly to <code>xxd -i</code> the directive is replaced by a comma separated list of integers corresponding to the data of the specified resource. More precisely, if an array of type {{code|unsigned char}} is initialized using an <code>#embed</code> directive, the result is the same as-if the resource was written to the array using <code>[[fread]]</code> (unless a parameter changes the embed element width to something other than <code>[[Limits.h|CHAR_BIT]]</code>). Apart from the convenience, <code>#embed</code> is also easier <!--than what?--> for compilers to handle, since they are allowed to skip expanding the directive to its full form due to the [[as-if rule]].
Line 139:
<syntaxhighlight lang="cpp">
const unsigned char
#embed "art.png"
};
/* specify any type which can be initialized form integer constant expressions will do */
const char
#embed "data.bin"
};
/* attributes work just as well */
const signed char
#embed "attributes.xml"
};
Line 468:
|title=An empirical analysis of c preprocessor use |journal=IEEE Transactions on Software Engineering |url = http://dl.acm.org/citation.cfm?id=631305
|date = December 2002
|volume=28 |issue=12 |pages=1146–1170 |doi=10.1109/TSE.2002.1158288 |bibcode=2002ITSEn..28.1146E |url-access=subscription }}</ref>
;Hidden multiple evaluation
|