Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using Visual studio 2008 and I want to use CRegKey class
for that I just include the file atlbase.h and after compile I'm getting following error

I have not used anything anywhere from that file I just included file and compiled that's it

Error 1 error C2668: 'ATL::InlineIsEqualUnknown' : ambiguous call to overloaded function C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\atlbase.inl 254

What I have tried:

#include "afxwin.h"
#include "Student.h"
#include "Teacher.h"
#include "Settings.h"
#include "About.h"
#include "BaseDlg.h"
#include "Label.h"
#include "XPButton.h"
//Here I included the atlbase.h file if i remove this statement then error is not coming
#include "atlbase.h"
Posted
Updated 27-Feb-17 23:11pm
v3
Comments
[no name] 28-Feb-17 0:08am    
This is not a good question. Posting the ATL header file under "What I have tried:" does not add any information. It is best to post a snippet of your code and explain the problem. The error C2668 has plenty of Google hits and some of them probably apply to you.
Use Improve question.
Premnath Mali 28-Feb-17 0:43am    
Sir the error is showing in that file thats why I put code under what I have tried
Now I added some code still getting same error
Jochen Arndt 28-Feb-17 3:07am    
Please show the top of the source file with all include and using (namespace) directives.

BTW:
You must set
ULONG lrn = MAX_PATH;
to tell CRegKey::QueryStringValue() the size of the buffer.

This is not the source of the error but might let your program not work as expected or even stop with an access violation.
Premnath Mali 28-Feb-17 4:18am    
Sir in my project if I include that file then this error showing if I remove that include statement then everything is fine my application is running accurately
please help
Jochen Arndt 28-Feb-17 4:30am    
When you got no error without including atlbase.h it is already included. However, then there should be no error.

You tagged your question with MFC. Then precompiled headers are used by default which requires including stdafx.h. But you have not included it. Have you disabled usage of precompiled headers?

When using precompiled headers, include stdafx.h as very first file.
Then include afxwin.h and atlbase.h from within stdafx.h too (if not already done).

1 solution

You tagged your question with MFC. Then precompiled headers are used by default which requires including stdafx.h.

So I guess that you forgot to include stdafx.h in your source file.

Then stdafx.h very likely includes atlbase.h already (directly with an include statement or indirectly by other files). Because your files compile without error when not including atlbase.h in the source files this will be the case here (otherwise there would be errors about unknown identifiers).

I'm not quite sure what really happened but forgetting to include that file can have many side effects.

Note also that afxwin.h is also already included by stdafx.h. So the top of your source file should look like:
// Include stdafx.h on top of all source files
//  before including any other file
#include "stdafx.h"
#include "Student.h"
#include "Teacher.h"
#include "Settings.h"
#include "About.h"
#include "BaseDlg.h"
#include "Label.h"
#include "XPButton.h"
// ATL and MFC system header files (afx*.h, atl*.h) should be included by stdafx.h
 
Share this answer
 
Comments
[no name] 28-Feb-17 18:53pm    
Well done.
Premnath Mali 1-Mar-17 1:18am    
I asked One more question please help me to solve
https://www.codeproject.com/Questions/1173553/How-to-create-save-and-retrieve-DWORD-value-to-reg
Premnath Mali 5-Mar-17 23:03pm    
Please help me to solve this one
https://www.codeproject.com/Questions/1174361/Asynchronous-method-invocation-in-mfc

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900