Reputation: 116273
This Verilog tutorial (see the table at the end) suggests that { }
is a concatenation operator is C. I don't remember curly brackets as being an operator in C.
Is { }
a concatenation operator in C?
Upvotes: 2
Views: 3983
Reputation: 753555
No, in pure C, the braces are not a concatenation operator.
Note that the table of operators on the Verilog page includes a number of other 'non-C, non-C++' operators:
~& nand
| or
~| nor
^ xor
^~ xnor
~^ xnor
Where the operators are the same as in C, they have the same meaning as in C. But there are operators in Verilog that are not in C (and, if that table is complete, operators in C that are not in Verilog).
Upvotes: 1
Reputation: 123448
From the linked tutorial:
To make life easier for us, nearly all operators (at least the ones in the list below) are exactly the same as their counterparts in the C programming language.
Emphasis mine. The exceptions are ~&
, ~|
, ~^
, ^~
, and {}
.
Adjacent string literals are automatically concatenated:
char *str = "This is the first half "
"and this is the second half";
Anything involving a char
buffer, though, requires a library function like strcat
:
char buf[SOME_SIZE];
...
strcat(buf, "This is the first half ");
strcat(buf, "and this is the second half");
There is also the preprocessor token pasting operator ##
, but the result must be a valid preprocessor token.
Upvotes: 3
Reputation: 145829
The only operator C has with { }
is the ( ){ }
operator which is the compound literal operator.
Upvotes: 1
Reputation: 9740
Depends. Curly brackets are not an operator by definition in C, and they do not concatenate strings. But they group statements and introduce new blocks. Maybe this is what the author meant. But however, it is at least inaccurate if not wrong.
Upvotes: 0
Reputation: 216273
Absolutely not. The curly braces in C as C++, C# and others delimit a block of code. It's an error on their site. There is neither the possibility of operator overloading since we talk of 'pure, old fashioned C programming language'
Upvotes: 2