Given:
void function(int*=0) {}
int main() {
}
clang (3.8.0):
test.cc:1:18: error: expected ')'
void function(int*=0) {
^
g++ (5.4.0):
test.cc:1:18: error: expected ‘,’ or ‘...’ before ‘*=’ token
void function(int*=0) {
^
If I change it to (note the spacing):
void function(int* = 0) {}
int main() {
}
Obviously it's getting confused whether I'm typing T* = 0 or T *= 0, is this a bug or expected?
(GNU C is a language, GCC is a compiler for that language.Clang defines __GNUC__ / __GNUC_MINOR__ / __GNUC_PATCHLEVEL__ according to the version of gcc that it claims full compatibility with.
● The driver provides convenience and compatibility ● clang-cl is a cl.exe compatible driver mode for clang ● It understands the environment, the flags, and the tools ● Integrates with Visual Studio ● /fallback allows bring-up of large projects.
Clang is designed to provide a frontend compiler that can replace GCC. Apple Inc. (including NeXT later) has been using GCC as the official compiler. GCC has always performed well as a standard compiler in the open source community.
TL;DR: Clang is highly compatible to GCC - just give it a go. In most cases, Clang could be used as a GCC drop in replacement ( clang and clang++ are "GCC compatible drivers").
*=
is one operator, like +=
is. So x *= 2;
is the same as x = x * 2;
You want * =
to be lexed as two tokens (conceptually in C++, lexing happens before, and nearly independently, of parsing; read about C++ translation phases).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With