bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#64204: C/C++ local variables not syntax highlighted if they start wi


From: Joseph Garvin
Subject: bug#64204: C/C++ local variables not syntax highlighted if they start with $
Date: Tue, 20 Jun 2023 15:54:52 -0500

Start emacs with `emacs -Q`, press C-x C-f and type in a filename that
ends in .cpp like "foo.cpp". Then type in:

int main()
{
    int a = 0;
    int b = 0;
    int $ = 0;
    int d$ = 0;
    int $e = 0;
}

Yes it compiles! GCC, Clang, and MSVC all have a non-standard
extension that allows $ signs to appear in C/C++ variable and type
names: https://gcc.gnu.org/onlinedocs/gcc/Dollar-Signs.html

Then a,b,d$ will be highlighted correctly as local vars, but not $ or
$e. The highlighting doesn't appear to work whenever $ is the first or
only character. Since emacs is accepting of the $ sign anywhere else in
the variable name, I suspect supporting $ was intended, even though it's
non-standard. Even if not intended, it's a popular syntax
extension supported by the major current compilers and whose history
goes back to the DEC compiler, so support would be nice.

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars)
 of 2021-05-14 built on eruv
Repository revision: efc24f1e0bb127481bcc9c3054c57c4cd3c99aa9
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Ubuntu 20.04.6 LTS


reply via email to

[Prev in Thread] Current Thread [Next in Thread]