Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 C++ wrong syntax coloring of pointer variable
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

tangens
New Member

Belgium
7 Posts

Posted - Nov 10 2011 :  09:56:27 AM  Show Profile  Reply with Quote
VAX wrongfully colors variable as a method/function when declaring a pointer variable with initialization using ()

int *myVariable(nullptr);


see attached image:
myVariable is colored as a method while
myVariable2 is colored as a variable.




system info:
VA_X.dll file version 10.6.1859.0 built 2011.10.02
DevEnv.exe version 10.0.40219.1 Professional
msenv.dll version 10.0.40219.1
Comctl32.dll version 6.10.7601.17514
Windows 7 6.1 Build 7601 Service Pack 1
4 processors (x86-64;
WOW64)

Platform: Custom
Stable Includes:
C:\\DevStudio\\Vs2010\\VC\\include;
C:\\DevStudio\\Vs2010\\VC\\atlmfc\\include;
C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\include;
C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\include;
C:\\DevStudio\\extra_x32\\Boost_1_43_0\\include;
C:\\DevStudio\\extra_x32\\Qt_4_7_0_x32_vs2010_dll\\include;
C:\\DevStudio\\extra_x32\\Cppunit_1_10_2_VS2010\\include;
C:\\DevStudio\\extra_x32\\gmock-1.4.0_vs2010\\include;
C:\\DevStudio\\extra_x32\\qxcppunit_x32_vs2010\\include;
C:\\DevStudio\\extra_x32\\QtWinMigrate_2.8.1_x32_vs2010\\src;

Other Includes:

Stable Source Directories:
C:\\DevStudio\\Vs2010\\VC\\atlmfc\\src\\mfc;
C:\\DevStudio\\Vs2010\\VC\\atlmfc\\src\\mfcm;
C:\\DevStudio\\Vs2010\\VC\\atlmfc\\src\\atl;
C:\\DevStudio\\Vs2010\\VC\\crt\\src;
C:\\DevStudio\\extra_x32\\Qt_4_7_0_x32_vs2010_dll\\src;
C:\\DevStudio\\extra_x32\\QtWinMigrate_2.8.1_x32_vs2010\\src;

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Nov 11 2011 :  3:20:13 PM  Show Profile  Reply with Quote
This "variable" is often called a "function pointer". It is a pointer to a function. So the function (where the variable is pointing to) is colored as a function :) I think that this is a borderline case and that the current working is reasonable. But let's see what others think about this :) I wouldn't say that either version is bad.

I checked and it seems to be consistent so both
int *myVariable(nullptr);
and
int (*myVariable2)(nullptr);
is colored as a function.

Edited by - accord on Nov 11 2011 3:25:24 PM
Go to Top of Page

tangens
New Member

Belgium
7 Posts

Posted - Nov 14 2011 :  04:03:25 AM  Show Profile  Reply with Quote
I don't agree that this is a function pointer.
It is a pointer to an int, but I happen to initialize it via () instead of =.

These are function pointers:



I would think they are distinguishable from pointer to int variables because of the data types between the (),
whereas my variable uses a value (nullptr in my case).
(I might go a bit too fast here, I might be missing some other cases?)
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Nov 14 2011 :  7:04:35 PM  Show Profile  Reply with Quote
*ooops* I was superficial and handled different things as they would have been the same. You are right indeed, your first example is an int pointer:

case=60805

However, your second example without the paren is a local function declaration:
int *myfunctionpointer(int);

You need parens to get a function pointer:
int (*myfunctionpointer)(int);

So we don't have to differentiate them based on the params. I messed up this in my first post but I was wrong.

Edited by - accord on Nov 14 2011 7:05:38 PM
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000