Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the use of "#@" in c language?

The # symbol is used at the start of preprocessor directives (#ifdef, #define etc). # is also used as the stringification operator.

## is the token pasting operator.

Then in an online quiz I saw this:

#define MAKECHAR(operand) #@operand

What operator is #@ and what is it used for?

like image 268
Malik Ji Avatar asked Nov 13 '18 12:11

Malik Ji


People also ask

What is the use of semicolon?

Use a semicolon to join two related independent clauses in place of a comma and a coordinating conjunction (and, but, or, nor, for, so, yet). Make sure when you use the semicolon that the connection between the two independent clauses is clear without the coordinating conjunction.

Where is the use of of?

We use of when we want to show that people or things relate to other things or people. For example, when we want to say that something or someone belongs to or is a part of something or someone else, we can do it like this: Tiffany stared at the floor of her room.

How do you use a colon and semicolon?

Semicolons should introduce evidence or a reason for the preceding statement; for example, this sentence appropriately uses a semicolon. A colon, on the other hand, should be used for a stronger, more direct relationship. It should provide emphasis, an example, or an explanation.

What's the use meaning?

idiom. used to say that it would not be useful to do something. "You should talk to her." "What's the use? She's not going to change her mind."


1 Answers

It is an analogy to the stringify marker # but for characters, but it is not standardized. For example, clang/llvm does not support it.

To show the analogy:

#define MESSAGE(x) printf("%s: %d\n", #x, x)

int main(){
    int i = 5;
    MESSAGE(i); // expands to printf("%s: %d\n", "i", x)
    return 0;
}

Output is:

i: 5

With a compiler supporting #@, you could write:

#define MESSAGE(x) printf("%c: %d\n", #@x, x)

int main(){
    int i = 5;
    MESSAGE(i);  // expands to printf("%c: %d\n", 'i', x)
    return 0;
}
like image 74
Stephan Lechner Avatar answered Sep 21 '22 16:09

Stephan Lechner