开发者

"precompiler directive" "preprocessor directive"

开发者 https://www.devze.com 2023-03-13 10:17 出处:网络
I was wondering if \"precompile(r) directive\" and \"preprocessor d开发者_高级运维irective\" are the same thing? I am not familiar with the former, but just heard of it and found a little information

I was wondering if "precompile(r) directive" and "preprocessor d开发者_高级运维irective" are the same thing? I am not familiar with the former, but just heard of it and found a little information about it on the internet with this Google search, such as p40 of "C++ programming for the absolute beginner" by Dirk Henkemans and Mark Lee.


Your question amounts to asking if people mean "preprocessor directive" when they say "precompile directive", and that's not an answerable question.


In a C or C++ context, I suspect people are very likely to be referring to preprocessor directives if they say "precompile directive".

The book you quote is one example of this. It's talking about the C preprocessor directive "#define". I suspect it's using "precompile directive" as a description, not a name.

All of the search results you posted that I examined are posts by people seeking help with C preprocessor directives.


That said, I can't say for certain that's the case for all people at all times, though.

Microsoft possibly made a tool that uses "precompiler directives" according to the result of another search I made, but it wasn't talking about C, C++ or cpp.


Yes, they sound like the exactly the same thing. I think preprocessor directive is more commonly used (I've never heard of precompiler).

This is a pretty good list of directives / what they do: http://www.cplusplus.com/doc/tutorial/preprocessor/


It depends a bit on context, but for most people most of the time, if you are working in pure C code, they are the same thing, though 'preprocessor directive' is far more common than 'precompile directive' or 'precompiler directive'.

Section §6.10 Preprocessing Directives of the ISO/IEC 9899:1999 standard indicates that 'preprocessor' or 'preprocessing' is more standard than 'precompile(r)'.

If, however, you work with ESQL/C (Embedded SQL in C), then there is a difference:

  • The precompiler directives are aimed at the ESQL/C precompiler, which converts ESQL/C into pure C.
  • The preprocessor directives are aimed at the C preprocessor, which is one part of the C compiler which (overall) converts C source code into object code or executables, etc.

The ESQL/C compiler I work with has directives such as:

$include sqlca;
$define APERITIF 32;
$include "header.h";
$ifdef APPETIZERS;
$define AVOCADO 1;
$endif;

#include <stdio.h>

int main(void)
{
    $ int var1;
    $ whenever error stop;
    $ database "whatever";
    $ select max(tabid) into :var1 from systables;
    printf("%d\n", var1);
    return 0;
}

The lines starting with a '$' are ESQL/C precompiler directives - aimed at the precompiler. They give the ESQL/C precompiler the information needed to help it convert the embedded SQL statements into C code, which is then compiled by a full C compiler. But the ESQL/C precompiler is also called the ESQL/C preprocessor (to distinguish it from the C preprocessor), so the distinction is not as hard and fast as all that. In this case, the ESQL/C compiler as a whole is a shell script that runs the ESQL/C precompiler and then the C compiler. (There are some extra complications in it that don't concern this question.)

0

精彩评论

暂无评论...
验证码 换一张
取 消