1

can you guys tell me, what does this mean in C?

 #define Privileged_Data
 Privileged_Data static int dVariable

Is it specific meaningful for Compiler to address variable?

0

2 Answers 2

7

This is just a macro Privileged_Data doing nothing. The compiler will not even see it after the preprocessor pass.

It's probably a readability or company standards decision to tag some variables like this.

Sign up to request clarification or add additional context in comments.

4 Comments

maybe a macro to be able to insert volatile or not.
Maybe in some configuration OP didn't show, perhaps.
A good example of this practice is Microsoft's SAL (Source Code Annotiation Language), where they mark the input parameters as _In_ and the output as _Out_
@Vect0rZ inout is cool to differentiate from out when passing a pointer to some data. for in and out you can use const pointer or not.
2

A preprocessor macro can be defined without an associated value. When that is the case, the macro is substituted with nothing after preprocessing.

So given this:

#define Privileged_Data

Then this:

Privileged_Data static int dVariable

Becomes this after preprocessing:

static int dVariable

So this particular macro has no effect on the program, and was probably put in place for documentation purposes.

3 Comments

Q: Is this considered good practise? To me as an old-timer C guy, it seems like abuse of a language feature.
@GermanNerd I would tend to agree. There are other ways to document code.
Nice to hear that. And thank you for your answer; initially this (ab)use of the #define directive had me really puzzled - like 'Is that something new in c99/c11/cxx....?'

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.