VC++ seems to not compile when needed

Hi,

I have a class implemented in a.cpp and a.h . (Class CA inherits from some other class)
I then add a virtual function declaration, f(), to CA in a.h, but add the implementation to another .cpp file, not a.cpp.
I press F7, and when running the instance of f() in the superclass is involved.

I have to actually modify a.cpp in order that the build actually compile the change and the f() in CA will be called.
In short, it seems like the default rules about what has to recompile are buggy.

Note: I use precompiled headers , but not for the specific a.h in question.

Is this a known bug? Is there a workaround in some compilation swithches? (i.e. I don't want to rebuild all or to remember to manually change a.cpp).
LVL 1
mcoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrwad99Commented:
You may want to download service pack 5 (SP5) for VC++, which you can get from the Microsoft site.

I dont know for sure if what you desribe is a documented problem, but I dont have this issue as far as I know and I have SP5 installed.

Hope this helps :)
0
mcoAuthor Commented:
I forgot to mention, I use VC++ version 6. Does what you mention still hold?
0
mrwad99Commented:
Yes I think so.  

If you have Visual Studio .NET then it does *not* hold, but if you just have Visual Studio then you need SP5 if it is not previously installed.  

Also what version of VC++ are you running ?  Professional ?
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

mcoAuthor Commented:
Enterprise
0
mrwad99Commented:
Well, either way try the service pack and come back :)
0
mcoAuthor Commented:
Tried the SP and it didn't help.
Later I also found that I already had SP5 beforehand - it just doesn't say it in the about box.
0
mrwad99Commented:
Sorry to hear that.  I am out of ideas.
0
mrwad99Commented:
Could you post the code you are using so I can have a fiddle on my machine please ?
0
mcoAuthor Commented:
My project is gigantic but I will try to create a sample project that reproduces the problem.
0
mrwad99Commented:
Nice one.  Hopefully the problem can be nailed then !
0
mcoAuthor Commented:
Since I don't see how I attach files here, please send me your email address to uiodocrawfd5@jetable.com and I will email you the sample
0
mcoAuthor Commented:
Will send soon.
I just checked it on Visual C 7 (.NET), and there the problem
does not occur anymore.
0
mrwad99Commented:
Hmm.  Interesting.  Looks like a problem with VC++ then !  Never heard of it before though, so it looks like you have your answer.  It would be interesting to still see your code though.
0
mcoAuthor Commented:
I still have a problem, though, because for real work I cannot switch to .NET (for unrelated reasons).
I am hoping to find some secret compilation switch or something.
0
mrwad99Commented:
Right I have had a good look at your code and experience exactly the same problem as you do.

>>This problem does not occur often, because by convention, a classe's methods are implemented
in the .cpp file of the class. In the example above this convention was not used.

Yeah that is the answer.  I am still a little confused as to why you chose to implement CDerived::f() from withinBuildProblemDlg.cpp, and not from within Derived.cpp; it would be interesting to hear your reasons.  All I can suggest is to create a pointer question to this question in both the C++ (again) and the MFC areas, possibly even the Windows Programming area too.  I am sure that someone out there must know, or at least have the resources to find out.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mrwad99Commented:
Hmm; interested at the fact that you decided to accept this as an answer, but ta anyway.  Personally I would have left it open.

Anyway best of luck in the future with your coding. :)
0
mcoAuthor Commented:
Hi, I accepted the answer in order to close this. From experience, after a number of days people don't see it and it just stays until I get some automatic email from EE. Thank you for your help.

The reason the function was not implemented in its conventional place has to do with the way our code is organized. Our codebase compiles in several configurations, with GUI to create a desktop application, and without GUI as a DLL that links to some COM interface.
The function in question (corresponding to f() in the sample), is GUI related. The .cpp file is general.
One solution would be to add #ifdefs for conditional compilation, but it was decided here it was better to put f() in the file dealing with GUI stuff.
In any case, we do not want to organize our code in other ways only because of bugs in VC++.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.