Author |
Topic |
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Dec 15 2005 : 4:09:44 PM
|
I have a library that uses a home-brewed smart pointer system in C++ (i.e. not STL, boost or anything else like it). This means that I have a templated class that defines:
template <class T> class MySmartPtr { public: T &operator *(); T *operator ->(); };
and so on. How difficult would it be to make VAX understand the implications of the declarations of the '*' and '->' operators?
In particular, that:
MySmartPtr<MyClass> MyPtr;
is a smart pointer to MyClass, so that it can understand:
MyPtr->
and expand the members of MyClass just as if MyPtr had been declared as:
MyClass *MyPtr;
instead?
|
Edited by - peck797 on Dec 15 2005 4:10:37 PM |
|
feline
Whole Tomato Software
United Kingdom
19001 Posts |
Posted - Dec 15 2005 : 5:42:33 PM
|
which version of VA are you using? template support is improved in the 14xx builds, so i am wondering how much of this template class VA already understands. |
zen is the art of being at one with the two'ness |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Dec 24 2005 : 12:19:20 PM
|
Currently running 10.2.1437. It may be related to the other problem that I reported about VA's confusion with namespaces? When I dereference the smart pointer that I have created, it only displays a balloon showing the smart pointer class, e.g. "MyClass *", not the members of the operator->() class |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Dec 24 2005 : 1:56:51 PM
|
After a false hope with v1438, where it seemed to work, the behaviour is now intermittent.
Sometimes it displays the list of methods and other times it will refuse to do so. This happens even if you try to resolve the same smart pointer on two successive lines. It will expand the first and then baulk when you repeat the construct later in the same function.
Occasionally, a message to the effect that "Intellisense couldn't resolve the symbol to the left of '.' or '->'" appears in the status bar but, again, this doesn't always happen.
|
|
|
feline
Whole Tomato Software
United Kingdom
19001 Posts |
Posted - Dec 27 2005 : 1:45:24 PM
|
strange. this almost sounds like something a little bit more fundamental. first up, are you getting suggestion listboxes some of the time, and completion boxes at other time? suggestion listboxes have a question mark icon in front of each item in the list, while completion listboxes have the standard IDE function, member, enum, etc icons.
http://www.wholetomato.com/products/features/members.html http://www.wholetomato.com/products/features/suggestion.html?more=yes
if this is the case then this would explain why you are getting different lists. if this is not the problem could you try turning on the VA option:
VA Options -> text editor -> listboxes -> get content from default intellisense
and let me know what effect this has? what are the options for getting a copy of your smart pointer class for me to run some tests with? it always helps if i am able to recreate a problem here.
the other factor here is that there could be something in your code that is confusing VA's C++ parser, which is why it stops producing sensible suggestions. however if this was happening i would expect this to effect other types as well. |
zen is the art of being at one with the two'ness |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Dec 28 2005 : 07:25:56 AM
|
I get the completion list boxes, or nothing at all or something that expands to the reference pointer type * operator. I haven't seen the "intellisense couldn't resolve" problem for a while now. The thing that is most odd is that it is not deterministic - you can get any of the possibilities when dereferencing the same pointer, even if you delete and retype the "->" on the same piece of code :)
Sure, I can send you some code but would prefer not to post it here. See separate email :)
I will try the content-from-intellisense option to see if the behaviour changes. |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Dec 28 2005 : 07:58:55 AM
|
Further to this, selecting "use default intellisense" option makes it much more likely to produce the "intellisense couldn't resolve the thing to the left of '.' or '->'" message in the status bar.
So it looks like my use of namespaces and/or smart pointers is really confusing the parser. I am also getting a lot of enum values marked with red underscores, implying that it really doesn't like something. But it all compiles fine.
They are declared right at the top of the header like this:
/* * Some vague copyright waffle */ #pragma once
namespace CBSockLib { typedef enum SocketErrorConstants { SocketErrorNone = -1, // Not set SocketErrorSuccess, // No error SocketErrorInternal, // Unexpected internal error (e.g. out of memory)
etc.
But are always displayed with red underscores when I use them in the .cpp files elsewhere. (Note that the header file itself does not underscore them with red marks, only the cpp files that try to use these constants.)
This header file is about three deep in the hierarchy:
base: #include "stdafx.h" includes: #include "one.h" which includes: #include "two.h" which includes: #include "enumHeader.h"
if that is relevant?
Maybe there's something it doesn't like in the other two? But, again, it all compiles fine, and those files themselves, don't show any red underscores.
|
Edited by - peck797 on Dec 28 2005 08:03:02 AM |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Dec 28 2005 : 08:44:41 AM
|
As this is now sitting in the front of my mind, I've started to notice a potential pattern here.
VAX seems much happier to decode the smart pointer if it is part of a class that is defined in the same project as the module that I am editing. I have about a dozen vcproj's in this particular solution and I get the impression that it is happening when the class is part of another project (but still in the solution).
For instance, I have a class called CBCritical and it lives in a library called CBUtils. It has a smart pointer called CBCriticalPtr and VAX has no problem listing the members of CBCritical when I edit a module that is also in the CBUtils project. If, however, I edit a module in another project but the same solution, VAX cannot dereference the CBCriticalPtr template class.
Does that help?
|
|
|
feline
Whole Tomato Software
United Kingdom
19001 Posts |
Posted - Dec 28 2005 : 3:57:26 PM
|
this is all most interesting. most of this sounds like the enum's and smart pointers are defined in a directory, or set of directories, that VA is not aware of.
the first way to test this is to open the OFIW and FSIW dialogs. can you see the file containing the unknown enum's in the OFIW dialog? if you cannot find it when you filter the list down can you scroll down and see if it is present without using filtering?
can you also do the same test for the actual enum's themselves in the FSIW dialog?
for now i want to focus on the enums if that is OK with you, since they are an easier thing to test and pin down. hopefully there is one root cause behind both the enums and the smart pointer class. |
zen is the art of being at one with the two'ness |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Dec 29 2005 : 07:22:58 AM
|
Please excuse the ignorance, but what are OFIW and FSIW?
The whole project sub-tree currently contains 928 directories (ouch!) but the ones that relate to this part of the project has only these bits:
.\\config .\\typelib .\\include .\\include\\sys .\\src .\\src\\ClientLib .\\src\\CryptLib .\\src\\FileLib .\\src\\MsgLib .\\src\\SockLib .\\src\\UtilsLib .\\src\\Client .\\src\\Shell .\\src\\Tray .\\test\\Server3
all based off the same root in the main project. The directory names that end in "Lib" contain static libraries; they also contain header files with enums in them. The other three projects under "src" are applications that use the libraries and show the above behaviour while editing them. The headers for the libraries are included in the application via "master header files" that live in the include and include/sys directories.
For example, the include directory will have a "fred.h" file that includes "sys/_fred.h" (and does other things). The file "sys/_fred.h" then includes "../../SockLib/sam.h" (and others).
The "Tray" application source includes the master-file "./include/fred.h". It uses some of the enums that are defined in "./src/SockLib/sam.h" and the compiler can find them just fine. But VAX underlines them with red, implying that it cannot find them. All but one of the static libraries uses its own namespace.
I hope that make sense. It's all rather convoluted and confuses me each time I look at it but hopefully I haven't simplified it too much by eliminating the other 913 directories from this description. :)
One other point that I hope is irrelevant. One of the directories contains two .vcproj files. Both these vcproj files use the same sources but with different compiler options (it wasn't sensible to use different configurations because of the effect on the other projects in the source tree).
|
Edited by - peck797 on Dec 29 2005 07:28:53 AM |
|
|
feline
Whole Tomato Software
United Kingdom
19001 Posts |
Posted - Dec 30 2005 : 10:14:04 AM
|
most people here recognise OFIW and FSIW, i just get used to using the short hand names is all.
OFIW = "Open File In Workspace", which is normally opened with ALT-SHIFT-O or the toolbar button FWIS = "Find Symbol In Workspace", which is normally opened with ALT-SHIFT-S or the toolbar button
do these static libraries contain cpp files? or are they only .h files? if it is only .h files you may not need to explicitly include them into one of the vcproj files which could be the source of the problems. VA's parser is not quite the same as a compiler, so unfortunately "the compiler finds the files" does not always help.
i am currently wondering if the compiler is finding these extra .h files by following the #include lines, but VA's parser is not finding them. the OFIW test should prove this one way or the other.
two vcproj files in the same directory should be no problems at all, i have used a solution with 20 in the same directory with no problems. |
zen is the art of being at one with the two'ness |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Dec 31 2005 : 06:53:13 AM
|
Oh, I hadn't noticed those dialogs before.
OFIW - This shows the files that contains the enums. In fact, VAX must know that they are there because Alt-G works for the enums, even though it is underlining them red.
FSIW - this does not show the enums, whether or not they are underlined red by VAX.
The libraries contain real code (.cpp files with class implementation). They are real libraries, not just placeholders - this is a fairly big project with dozens of EXEs, DLLs etc. The headers are the declarations for the classes that are in the libraries. These classes are used by the other libraries and by the DLLs/EXEs. It's a fairly standard architecture, I think.
|
Edited by - peck797 on Dec 31 2005 06:55:11 AM |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
|
feline
Whole Tomato Software
United Kingdom
19001 Posts |
Posted - Dec 31 2005 : 12:58:10 PM
|
these threads could be related, although they are specific to COM smart pointers. are you using COM in your library code?
*experiments* it seems that enum types and values are never listed in FSIW, so that is not actually proving anything either way. the files being listed in OFIW suggests that this should just be working. are the SocketErrorConstants enum items actually used in the library code? i presume they are, but this is just me guessing.
if you can easily find a use of the enum values, is this reference coloured by VA as an enum?
VA options -> environment -> fonts and colours -> preprocessor macros
as a test i placed the following code into a .h file:
namespace CBSockLib
{
typedef enum SocketErrorConstants
{
SocketErrorNone = -1, // Not set
SocketErrorSuccess, // No error
SocketErrorInternal, // Unexpected internal error (e.g. out of memory)
SocketErrorMinor
};
}
when i then type:
CBSockLib::Soc|
into the matching cpp file VA quite happily suggests the type "SocketErrorConstants". accepting that, and typing:
CBSockLib::SocketErrorConstants::|
i am then presented with a list of the enum values. can you try the same test please, and see what you get?
i did this test using C++, VA 1438 and VS2003. which IDE are you using? this could be relevant, although it seems unlikely. |
zen is the art of being at one with the two'ness |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Dec 31 2005 : 1:07:56 PM
|
That works fine. I get the red underscore only when I try to refer to an enum that is in another project in the same solution. If I refer to an enum that is in the same project within the solution, then it can find the enum OK.
And, no, it doesn't colour them as an enum because it thinks it's an error, hence the red underscore.
I'm running 1438 on VS 2003 as per your test.
Did you get my email? If you send me a response, then I can try to reproduce it in a real-world example. |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Dec 31 2005 : 1:10:17 PM
|
re: smart pointers, some of the projects use COM, yes. But not all and the effect is the same on those that do and those that don't.
Did you consider my comment about the key feature being whether or not the definition is in the same project? Your example implies to me that you haven't noticed it or think it's not relevant? :)
|
Edited by - peck797 on Dec 31 2005 1:10:48 PM |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Jan 01 2006 : 07:02:24 AM
|
Today, either the behaviour is different or I am going blind. It is colouring the enums as enums after all, but it is still underscoring them red. Alt-G correctly goes to the definition, despite the underscore.
I'm not sure whether I was doing something different yesterday, sorry. But this is starting to get very confusing.
The problem with smart pointers seems to come after I have edited a few lines. The first time that I loaded the workspace after powering up this morning, there were no underscores and everything was working. It even managed to dereferencing the very first smart pointer that I used (one that was failing before, it refers to a definition in another project).
After the first edit to that file, though, the red underscores started to appear and it went back to the "can't find the members of the smart pointer" mode again.
Is there a storage limit that we are exceeding perhaps?
Happy New Year :)
|
Edited by - peck797 on Jan 01 2006 07:04:19 AM |
|
|
feline
Whole Tomato Software
United Kingdom
19001 Posts |
Posted - Jan 03 2006 : 3:58:36 PM
|
email? my inbox is a slight disaster area, i will have a hunt through the unread items and see what i can find.
*checks*
the most recent email sent from the forum was received 13th December. there is nothing that looks like an email from you in the last week, and i hunted through my junk email folder as well. did you send it to [email protected] ? if so i do not have access to that email account.
i have just emailed you via the forum, if you reply to that email it should reach me just fine. i avoid giving out my email on the forums to try and cut down on spam
all right, what you are reporting does actually make a strange form of sense. when you first open a file VA does not attempt to find and underline mistyped symbols - this is a decision to increase speed if you are only passing through a file and not actually doing any editing.
once you start editing the file then VA will check for mistyped symbols and underline them.
as for enums defined in a different project, i regularly use the Qt C++ framework, which i have setup as a second project in a solution, and enum's from this are correctly recognised, coloured, and are never underlined as mistyped.
it is almost as if there is something in your code or project settings that is confusing the parser, but what? |
zen is the art of being at one with the two'ness |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Jan 03 2006 : 6:41:22 PM
|
I'm not so convinced that the parser is confused, in the enum case. Did you notice my comment that Alt-G works, even when the enums are underlined red? How can that work if the parser could not find the symbol definition?
I haven't got your email yet (unless you have disguised it as some form of advert for masculine-enhancement products). When I emailed you it was via this forum, too. It didn't tell me what your "real" address was.
|
|
|
feline
Whole Tomato Software
United Kingdom
19001 Posts |
Posted - Jan 04 2006 : 3:54:17 PM
|
this is very strange. i have just re-emailed you via the forum. normally emails via the forum reach me with no problems. hopefully this was a one off problem.
i did notice your comment about alt-g working, but don't really know what to make of it to be honest. something is clearly going wrong here, but since you seem to be the only person with this particular problem it is probably related to your solution setup or code confusing VA somehow. |
zen is the art of being at one with the two'ness |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Jan 04 2006 : 6:22:42 PM
|
You have mail! I hope it works because it's taken me all evening to get the code in a form that I can send that shows the problem but without timed explosive charges attached :)
I did try, at first, to reproduce the problem by building a test app from scratch but couldn't make it happen. So there's something odd about this particular project.
|
|
|
feline
Whole Tomato Software
United Kingdom
19001 Posts |
Posted - Jan 05 2006 : 3:02:56 PM
|
the email arrived just fine. initial tests jumping directly to point 5 and doing some edits were not so successful:
i am now off to do some more tests and see what happens. |
zen is the art of being at one with the two'ness |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Jan 05 2006 : 3:38:25 PM
|
I wonder if it's the Boost templates? They are fairly heavy things |
|
|
feline
Whole Tomato Software
United Kingdom
19001 Posts |
Posted - Jan 05 2006 : 4:58:54 PM
|
all right, i have worked through the instructions in the email, but the project will not compile. i am getting:
src\\ChibisClient\\ChibisClient.rc(133): error RC2135 : file not found: ChibisClient.tlb
i have done a find and i do not have this file. ignoring this problem for the moment, i still cannot reproduce the enum underlining problem. do you have a second test system available to you? if so are you able to reproduce the problem there?
i still wonder if there is a connection between this enum problem and the smart pointer problem you are having. are there any smart pointers being used in the code that you sent me? if so i can do some initial tests to see what happens.
i have boost 1.33.1 on this test machine - but not active, and we have various users who use boost and do not seem to get problems like this. this does not prove anything, but initially it suggests boost is not the cause of these problems. |
zen is the art of being at one with the two'ness |
Edited by - feline on Jan 05 2006 5:00:28 PM |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Jan 05 2006 : 6:35:50 PM
|
OK.
The tlb file is produced by the compilation of the MIDL file in ChbisClient and isn't needed to show the problem. It's probably because I simplified the project to the point of losing some of the include dependencies - it's probably put the tlb file into a "strange" place (typelib/debug?) for the hacked build that I sent to you. The TLB isn't actually needed for you to complete the build so you could either find the file (wherever it has written it and copy it to the ChibisClient source folder, so that it doesn't need to look for the file elsewhere. Alternatively, just delete the offending line from the rc file.
As for smart pointers create or look for something that ends in "Ptr", such as CBSockClientPtr or CBSockStreamPtr:
. CBSockClientPtr client;
then try to dereference it:
. client->
and see if it lists the methods. The problem with this one is that it is not consistent. Sometimes, it will do the expansion and other times, it will not. The enum behaviour is consistent (fails everytime for me but works everytime for you!) Still it's worth a try.
Is there any way that I can enable some useful debug that will show you what's happening inside VAX? Otherwise, we're probably just going to have to assume it's something peculiar to my machine. |
|
|
feline
Whole Tomato Software
United Kingdom
19001 Posts |
Posted - Jan 08 2006 : 5:09:43 PM
|
all right. i did a find in files, and it picked up:
\\src\\CBSockLib\\CBSockClient.cpp
as a file containing "CBSockClientPtr"
there is an instance of this smart pointer called "object". on the following code lines in this function i added "object->" and watched to see if VA 1438 would give me the correct suggestion list:
lines 66, 74, 79, 87, 89, 91, 95, 97, 99, 101, 106, 108, 111, 115
in each case i got the same list of items, no problems. this is a different list to "object." so i believe this is working correctly. from what you have said you would expect this to fail before then. can you try the same experiment on the code you sent me? the line numbers only make sense if you do all of the preceding inserts, since each of these adds a new line of code. |
zen is the art of being at one with the two'ness |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Jan 08 2006 : 6:58:25 PM
|
Unfortunately for this test, this case is the one that works for me, given that CBSockClientPtr is defined within this same project. You would need to add your code to a file in one of the other projects to see the problem. This is why I suggested that you add it to teh WinMain function.
When I use a smart pointer in the same project, the VAX always works. When I use it in another project, then the smart pointer sometimes works.
But, given that you cannot reproduce the enum colouring problem, I think it might have something to do with my particular machine. Hence the questions about caches overflowing etc. |
|
|
feline
Whole Tomato Software
United Kingdom
19001 Posts |
Posted - Jan 09 2006 : 4:16:01 PM
|
ahha! after moving into "src\\ChibisClient\\ChibisClient.cpp" and adding a comment i am now getting enum's underlined.
case=957
this suggests i should be able to reproduce the smart pointer problem as well. i had thought my last test with the enum's should have reproduced this underlining, but it did not. did i miss something obvious?
in "src\\ChibisClient\\ChibisClient.cpp" i added the global item:
CBSockClientPtr object;
at line 23. i then added "object->|" items at lines 30, 31, 38, 39, 41, 42, 44, 52, 53, 55, 56, 69, 70, 78, 79, 81, 82, 88, 89, 92, 93, 101, 102, 104, 105, 108, 109, 111, 113, 121, 123, 126, 128, 130, 138, 144
as usual it worked perfectly every time. this time i double checked, and the class is defined in a different project. |
zen is the art of being at one with the two'ness |
|
|
feline
Whole Tomato Software
United Kingdom
19001 Posts |
Posted - Jan 09 2006 : 4:24:17 PM
|
quote: Originally posted by peck797
Is there any way that I can enable some useful debug that will show you what's happening inside VAX? Otherwise, we're probably just going to have to assume it's something peculiar to my machine.
you can always produce a log file, this is simply turned on in VA options -> performance -> general -> enable logging
the problem with this is that the files get large fairly quickly, so it is best if you can reproduce the problem on demand. i am not sure if you have got the smart pointer problem to this state.
do you have a second test machine that you could try this sample project you emailed me on? |
zen is the art of being at one with the two'ness |
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Jan 09 2006 : 4:27:41 PM
|
Yes, the smart pointer problem is not 100% for me either.
I think it's worse when the project grows and gets more complicated - hence my thoughts about caches overflowing. But this is a woolly feeling at the moment, so probably not worth you trying to reproduce. It seems always to work when I am in the same namespace as the corresponding declaration though. (FYI, you will find that CBSockClientPtr is declared in CBSockClient.h via a macro - CB_DECLARE_REFPTR(CBSockClient).)
But, as I say, small projects tend to work. The solution I have here is about a dozen projects with about 200 files in total.
|
|
|
peck797
Tomato Guru
United Kingdom
171 Posts |
Posted - Jan 09 2006 : 4:28:54 PM
|
I've lost the ZIP file that I sent to you :( Can you send it back to me? |
|
|
Topic |
|