|
The #include directives are a liitle convoluted but seem right af first sight. Could it be some of your safeguard #ifndef s are duplicated in your header files? (just a hunch)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
The #include directives are a liitle convoluted but seem right af first sight.
The includes are definitely convoluted. We had some serious compilation time problems (like it was always recompiliing and each time took 5 minutes or so). So I read that Large-Scale C++ Design (Lakos - great book) and finally learned how it all worked.
The trouble is, part of this project was written by a C programmer and another part by a math grad just out of school. OO is new to them and so they don't follow the whole dependancy thing. And I didn't have time to explain it all.
So I ripped out all of the #includes, and hit F7. Added the first #include or forward definition (whichever was necessary) and then hit F7 again. 250 files worth. Took a while, but finally things compile at a reasonable speed and the only stuff that needs a "rebuild-all" frequently is the new math grad's stuff.
Joaquín M López Muñoz wrote:
Could it be some of your safeguard #ifndefs are duplicated in your header files?
I don't think this is a problem but I'll check. I religiously only use one #ifndef per header and none in the .cpp files except MS's debug new stuff.
J
|
|
|
|
|
Another effective way to know wheter the code for CObjectCache is actually included is to insert an #error directive just in the middle of it. If the error does not pop up, something bad is happening
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
Another effective way to know wheter the code for CObjectCache is actually included is to insert an #error directive just in the middle of it. If the error does not pop up, something bad is happening
Excellent. I will remember this technique, thanks.
But in this case, it pops up a billion times - once for each time the file is included.
J
|
|
|
|
|
Well, this is shooting in the dark, but I guess your desperation justifies desperate measures. Try (if you like) copying and pasting the whole CObjectCache definition in one of the offending .cpp , just above the class that uses it. This is not a fix, just a test to see how the compiler behaves.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
Well, this is shooting in the dark, but I guess your desperation justifies desperate measures.
I shot, and it wasn't at all the problem, but it led me to it!!
I guess I don't quite understand templates yet... In the same way you add a forward declaration of a classA to a header file defining classB if a classB contains a pointer to classA (has-a), I had added a forward declaration of my template to one of the other header files.
When I copied the CObjectCache definition in front of the CFLAWDoc class, a bunch of things broke because of redefinitions... and in removing everything that caused the redefinitions, I came across that forward declaration.
Anyways, the forward is gone, the template definition is back to where it should be, and everything compiles and runs just fine.
Thank you sir. While you didn't actually find my problem, it probably would have taken me another day or two to find it without your suggestions.
Next time you're in Toronto, beers are on me.
J
|
|
|
|
|
Next time you're in Toronto, beers are on me.
Hey, glad to be helpful! Never been to Toronto, but came close a couple of years ago (tripped from Nova Scotia to Montreal, beautiful landscape).
The point you raised about forward declarations is interesting. As far a I know one can forward declare templates just like regular classes, and there's no VC++ bug about this feature that I know of. It'd be interesting to try to isolate this behavior in a tiny example (I'll might do it if I had some time spare), maybe you've hit a compiler bug.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Ok, here's something...
When I change it to a pointer member and change the CFLAWDoc constructor to "new" it, the compiler complains about 'CObjectCache<class CDataSlice>' : class has no constructors.
Now I've seen this before but only when the compiler has only seen a forward declaration and not the entire definition. Once again, I checked the preprocessor output and everything seems to be in place.
J
|
|
|
|
|
A shot in the dark ...
try putting typename in front of your CObjectCache variable declaration. If there is some confusion on the part of the compiler, maybe that will clear it up (or output a better error message).
CodeGuy
The WTL newsgroup: over 1300 members! Be a part of it. http://groups.yahoo.com/group/wtl
|
|
|
|
|
CodeGuy wrote:
try putting typename in front of your CObjectCache variable declaration. If there is some confusion on the part of the compiler, maybe that will clear it up (or output a better error message).
Not sure what you mean really. I can't put it in front of the type in the allocation statement:
m_pCache = new typename CObjectCache<CDataslice>(2000);
because typename is only allowed inside a template. And it doesn't seem to do anything except provide an alias for a type inside the template.
J
|
|
|
|
|
Have you tried renaming the class ? I've had different problems in the past where I found my core problem was a class named after an MFC class, or a function named after one that MFC or ATL puts in there also, somewhere in the inheritance chain.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
There is also the problem that if you name your H file after one of the system includes, it won't check for time changes. That one is a ***** to figure out.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim Smith wrote:
There is also the problem that if you name your H file after one of the system includes, it won't check for time changes.
Nope, I did a full search and there isn't anything that looks like my filename in the entire VS install. Nor is there anything in a full MSDN search with the same name.
I'm totally stumped.
J
|
|
|
|
|
Christian Graus wrote:
Have you tried renaming the class ?
Just tried it. Didn't help. But thanks.
I've looked through the preprocessor output and it's sitting right there.
It's as if it knows that CObjectCache is defined, and that CContainedObject is defined, but somehow CObjectCache<CContainedObject> isn't.
Does that make any sense?
J
|
|
|
|
|
I need a routine to save an icon to disc as an .ico file, or failing that copy an icon to the clipboard. Anybody know of one?
I'm never gonna work another day in my life. The gods told me to relax, They said I'm gonna get fixed up right. Monster Magnet, Powertrip
|
|
|
|
|
lookup the ICONINFO structure and search MSDN for the article "Icons in Win32"
- Roman -
|
|
|
|
|
Thanks!
I'm never gonna work another day in my life. The gods told me to relax, They said I'm gonna get fixed up right. Monster Magnet, Powertrip
|
|
|
|
|
Hey ! Anyone know how can i display a popup menu at top of mouse cursor(from bottom to top), anytime, even if the mouse isn't at the bottom of screen, and windows doesn't have to display the menu from bottom to top.
|
|
|
|
|
Do you mean you want the menu to be outside the screen?
I'm not sure of it if that is your question....
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
no... i didn't meant that...
i meant that if the mouse cursor is too close of the top of the screen to display the menu at bottom of the cursor, and normaly, by default, from down to top...
try to install trillian, and click the trilli button, and see where the menu is going from to where...
cheers
|
|
|
|
|
How can I get the string from a CString to a char*/char????
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
strcpy() or strncpy()
I'm never gonna work another day in my life. The gods told me to relax, They said I'm gonna get fixed up right. Monster Magnet, Powertrip
|
|
|
|
|
Holy god damnit!
I was soooooo sure it wouldn't work!
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Must remember: the reason CString is so popular is MS made it easy for lazy programmers to use, and if you can't be a lazy programmer, then what's the point?
I'm never gonna work another day in my life. The gods told me to relax, They said I'm gonna get fixed up right. Monster Magnet, Powertrip
|
|
|
|
|
I have an active control which i need to insert during runtime . Assuming that the Active x class name is CActivex , how do i dynamically create windows and place them in an order for a MFC Dialog application ?
thanks
|
|
|
|