473,897 Members | 3,236 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ambiguous symbol error

I have done a program with windows forms in "Visual C++". I have implemented a function that returns two values. For example:

double functionExample (int parameter, [Out] double __gc* result2);

And in a header file, I have written this line:

using namespace System::Runtime ::InteropServic es;

This line is necessary for [Out] key word. But when compiling the project, I get this error:

C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\Platfo rmSDK\Include\W inBase.h(3140): error C2872: 'FILETIME' : ambiguous symbol could be 'C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\Platfo rmSDK\Include\W inDef.h(354) : _FILETIME FILETIME' or 'stdafx.cpp(0) : System::Runtime ::InteropServic es::FILETIME'

How can I solve it? Thanks.

--
Message posted via http://www.dotnetmonster.com
Nov 17 '05 #1
5 2557
You could try using:
#undef FILETIME
using namespace System::Runtime ::InteropServic es;

You're unlikely to need the version in WinDef.h in this compilation unit.
This sort of thing's quite common (MessageBox is one) and occurs because the
standard Windows headers (usually included from <windows.h>) have a load of
#defines that clash with .NET-defined stuff.

Steve

"rodri rodri via DotNetMonster.c om" <fo***@DotNetMo nster.com> wrote in
message news:d9******** *************** *******@DotNetM onster.com...
I have done a program with windows forms in "Visual C++". I have
implemented a function that returns two values. For example:

double functionExample (int parameter, [Out] double __gc* result2);

And in a header file, I have written this line:

using namespace System::Runtime ::InteropServic es;

This line is necessary for [Out] key word. But when compiling the project,
I get this error:

C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\Platfo rmSDK\Include\W inBase.h(3140): error C2872: 'FILETIME' :
ambiguous symbol could be 'C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\Platfo rmSDK\Include\W inDef.h(354) : _FILETIME FILETIME' or
'stdafx.cpp(0) : System::Runtime ::InteropServic es::FILETIME'

How can I solve it? Thanks.

--
Message posted via http://www.dotnetmonster.com

Nov 17 '05 #2
Thank you for answering me. I have tried to solve it writing:
#undef FILETIME

But the problem does not get solved and keeps on giving the same error.

"File1.h" has this line: "using namespace System::Runtime ::InteropServic es;"
And "Form1.cpp" has this line: "#include <windows.h>

/*File1.h*/

#pragma once

using namespace System::Runtime ::InteropServic es;

public __gc __interface interface1
{
public:
double function1(int parameter, [Out] double __gc& result2);
};
/*Form1.h*/

#include "stdafx.h"
#include "Form1.h"
#include <windows.h>

using namespace namespace1;

int APIENTRY _tWinMain(HINST ANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threadi ng::Thread::Cur rentThread->ApartmentSta te =
System::Threadi ng::ApartmentSt ate::STA;
Application::Ru n(new Form1());
return 0;
}
/*stdafx.h*/

#pragma once

#define WIN32_LEAN_AND_ MEAN

#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>

#include "File1.h"
----------------------------------------------------------
"Steve McLellan" wrote:
You could try using:
#undef FILETIME
using namespace System::Runtime ::InteropServic es;

You're unlikely to need the version in WinDef.h in this compilation unit.
This sort of thing's quite common (MessageBox is one) and occurs because the
standard Windows headers (usually included from <windows.h>) have a load of
#defines that clash with .NET-defined stuff.

Steve

"rodri rodri via DotNetMonster.c om" <fo***@DotNetMo nster.com> wrote in
message news:d9******** *************** *******@DotNetM onster.com...
I have done a program with windows forms in "Visual C++". I have
implemented a function that returns two values. For example:

double functionExample (int parameter, [Out] double __gc* result2);

And in a header file, I have written this line:

using namespace System::Runtime ::InteropServic es;

This line is necessary for [Out] key word. But when compiling the project,
I get this error:

C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\Platfo rmSDK\Include\W inBase.h(3140): error C2872: 'FILETIME' :
ambiguous symbol could be 'C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\Platfo rmSDK\Include\W inDef.h(354) : _FILETIME FILETIME' or
'stdafx.cpp(0) : System::Runtime ::InteropServic es::FILETIME'

How can I solve it? Thanks.

--
Message posted via http://www.dotnetmonster.com


Nov 17 '05 #3
Hi,

This example code doesn't make sense; the code labelled as Form1.h is (I
presume) meant to be Form1.cpp but Form1.h doesn't appear to be present.
Where did you put the #undef FILETIME? It needs to come after #include
<windows.h> but before using namespace System::Runtime ::InteropServic es

If this still doesn't work, then it may be something else, but I've seen
this problem before (though not specifically with FILETIME) and it's been
due to this kind of name clash every time.

Steve
"rahoo" <ra***@discussi ons.microsoft.c om> wrote in message
news:81******** *************** ***********@mic rosoft.com...
Thank you for answering me. I have tried to solve it writing:
#undef FILETIME

But the problem does not get solved and keeps on giving the same error.

"File1.h" has this line: "using namespace
System::Runtime ::InteropServic es;"
And "Form1.cpp" has this line: "#include <windows.h>

/*File1.h*/

#pragma once

using namespace System::Runtime ::InteropServic es;

public __gc __interface interface1
{
public:
double function1(int parameter, [Out] double __gc& result2);
};
/*Form1.h*/

#include "stdafx.h"
#include "Form1.h"
#include <windows.h>

using namespace namespace1;

int APIENTRY _tWinMain(HINST ANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threadi ng::Thread::Cur rentThread->ApartmentSta te =
System::Threadi ng::ApartmentSt ate::STA;
Application::Ru n(new Form1());
return 0;
}
/*stdafx.h*/

#pragma once

#define WIN32_LEAN_AND_ MEAN

#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>

#include "File1.h"
----------------------------------------------------------
"Steve McLellan" wrote:
You could try using:
#undef FILETIME
using namespace System::Runtime ::InteropServic es;

You're unlikely to need the version in WinDef.h in this compilation unit.
This sort of thing's quite common (MessageBox is one) and occurs because
the
standard Windows headers (usually included from <windows.h>) have a load
of
#defines that clash with .NET-defined stuff.

Steve

"rodri rodri via DotNetMonster.c om" <fo***@DotNetMo nster.com> wrote in
message news:d9******** *************** *******@DotNetM onster.com...
>I have done a program with windows forms in "Visual C++". I have
>implemented a function that returns two values. For example:
>
> double functionExample (int parameter, [Out] double __gc* result2);
>
> And in a header file, I have written this line:
>
> using namespace System::Runtime ::InteropServic es;
>
> This line is necessary for [Out] key word. But when compiling the
> project,
> I get this error:
>
> C:\Program Files\Microsoft Visual Studio .NET
> 2003\Vc7\Platfo rmSDK\Include\W inBase.h(3140): error C2872: 'FILETIME' :
> ambiguous symbol could be 'C:\Program Files\Microsoft Visual Studio
> .NET
> 2003\Vc7\Platfo rmSDK\Include\W inDef.h(354) : _FILETIME FILETIME' or
> 'stdafx.cpp(0) : System::Runtime ::InteropServic es::FILETIME'
>
> How can I solve it? Thanks.
>
> --
> Message posted via http://www.dotnetmonster.com


Nov 17 '05 #4
If you look at the diagnostics that the OP got, you will realize
that the problem cannot be a preprocessor issue. The name
that gives rise to the ambiguity, (as a result of an unfortunate
use of the 'using' directive), is declared in both the global
namespace and the namespace he has dumped via 'using'.
He can #undef that name until Hell freezes over, but since
it was never #define'd in the first place, it will do no good.

When the OP finally fixes this, it will be by some variation
on the advice I gave days ago. Until then, all I can say is:
Have fun fiddling with the irrelevant preprocessor.

--
--Larry Brasfield
email: do************* **********@hotm ail.com
Above views may belong only to me.

"Steve McLellan" <sjm AT fixerlabs DOT com> wrote in message
news:uM******** *****@TK2MSFTNG P11.phx.gbl...
Hi,

This example code doesn't make sense; the code labelled as Form1.h is (I presume) meant to be Form1.cpp but Form1.h doesn't appear
to be present. Where did you put the #undef FILETIME? It needs to come after #include <windows.h> but before using namespace
System::Runtime ::InteropServic es

If this still doesn't work, then it may be something else, but I've seen this problem before (though not specifically with
FILETIME) and it's been due to this kind of name clash every time.

Steve
"rahoo" <ra***@discussi ons.microsoft.c om> wrote in message news:81******** *************** ***********@mic rosoft.com...
Thank you for answering me. I have tried to solve it writing:
#undef FILETIME

But the problem does not get solved and keeps on giving the same error.

"File1.h" has this line: "using namespace System::Runtime ::InteropServic es;"
And "Form1.cpp" has this line: "#include <windows.h>

/*File1.h*/

#pragma once

using namespace System::Runtime ::InteropServic es;

public __gc __interface interface1
{
public:
double function1(int parameter, [Out] double __gc& result2);
};
/*Form1.h*/

#include "stdafx.h"
#include "Form1.h"
#include <windows.h>

using namespace namespace1;

int APIENTRY _tWinMain(HINST ANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threadi ng::Thread::Cur rentThread->ApartmentSta te =
System::Threadi ng::ApartmentSt ate::STA;
Application::Ru n(new Form1());
return 0;
}
/*stdafx.h*/

#pragma once

#define WIN32_LEAN_AND_ MEAN

#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>

#include "File1.h"
----------------------------------------------------------
"Steve McLellan" wrote:
You could try using:
#undef FILETIME
using namespace System::Runtime ::InteropServic es;

You're unlikely to need the version in WinDef.h in this compilation unit.
This sort of thing's quite common (MessageBox is one) and occurs because the
standard Windows headers (usually included from <windows.h>) have a load of
#defines that clash with .NET-defined stuff.

Steve

"rodri rodri via DotNetMonster.c om" <fo***@DotNetMo nster.com> wrote in
message news:d9******** *************** *******@DotNetM onster.com...
>I have done a program with windows forms in "Visual C++". I have
>implemented a function that returns two values. For example:
>
> double functionExample (int parameter, [Out] double __gc* result2);
>
> And in a header file, I have written this line:
>
> using namespace System::Runtime ::InteropServic es;
>
> This line is necessary for [Out] key word. But when compiling the project,
> I get this error:
>
> C:\Program Files\Microsoft Visual Studio .NET
> 2003\Vc7\Platfo rmSDK\Include\W inBase.h(3140): error C2872: 'FILETIME' :
> ambiguous symbol could be 'C:\Program Files\Microsoft Visual Studio .NET
> 2003\Vc7\Platfo rmSDK\Include\W inDef.h(354) : _FILETIME FILETIME' or
> 'stdafx.cpp(0) : System::Runtime ::InteropServic es::FILETIME'
>
> How can I solve it? Thanks.
>
> --
> Message posted via http://www.dotnetmonster.com



Nov 17 '05 #5
Hi,

My apologies.

Steve

"Larry Brasfield" <do************ ***********@hot mail.com> wrote in message
news:eK******** ******@TK2MSFTN GP15.phx.gbl...
If you look at the diagnostics that the OP got, you will realize
that the problem cannot be a preprocessor issue. The name
that gives rise to the ambiguity, (as a result of an unfortunate
use of the 'using' directive), is declared in both the global
namespace and the namespace he has dumped via 'using'.
He can #undef that name until Hell freezes over, but since
it was never #define'd in the first place, it will do no good.

When the OP finally fixes this, it will be by some variation
on the advice I gave days ago. Until then, all I can say is:
Have fun fiddling with the irrelevant preprocessor.

--
--Larry Brasfield
email: do************* **********@hotm ail.com
Above views may belong only to me.

"Steve McLellan" <sjm AT fixerlabs DOT com> wrote in message
news:uM******** *****@TK2MSFTNG P11.phx.gbl...
Hi,

This example code doesn't make sense; the code labelled as Form1.h is (I
presume) meant to be Form1.cpp but Form1.h doesn't appear
to be present. Where did you put the #undef FILETIME? It needs to come
after #include <windows.h> but before using namespace
System::Runtime ::InteropServic es

If this still doesn't work, then it may be something else, but I've seen
this problem before (though not specifically with
FILETIME) and it's been due to this kind of name clash every time.

Steve
"rahoo" <ra***@discussi ons.microsoft.c om> wrote in message
news:81******** *************** ***********@mic rosoft.com...
Thank you for answering me. I have tried to solve it writing:
#undef FILETIME

But the problem does not get solved and keeps on giving the same error.

"File1.h" has this line: "using namespace
System::Runtime ::InteropServic es;"
And "Form1.cpp" has this line: "#include <windows.h>

/*File1.h*/

#pragma once

using namespace System::Runtime ::InteropServic es;

public __gc __interface interface1
{
public:
double function1(int parameter, [Out] double __gc& result2);
};
/*Form1.h*/

#include "stdafx.h"
#include "Form1.h"
#include <windows.h>

using namespace namespace1;

int APIENTRY _tWinMain(HINST ANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threadi ng::Thread::Cur rentThread->ApartmentSta te =
System::Threadi ng::ApartmentSt ate::STA;
Application::Ru n(new Form1());
return 0;
}
/*stdafx.h*/

#pragma once

#define WIN32_LEAN_AND_ MEAN

#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>

#include "File1.h"
----------------------------------------------------------
"Steve McLellan" wrote:

You could try using:
#undef FILETIME
using namespace System::Runtime ::InteropServic es;

You're unlikely to need the version in WinDef.h in this compilation
unit.
This sort of thing's quite common (MessageBox is one) and occurs
because the
standard Windows headers (usually included from <windows.h>) have a
load of
#defines that clash with .NET-defined stuff.

Steve

"rodri rodri via DotNetMonster.c om" <fo***@DotNetMo nster.com> wrote in
message news:d9******** *************** *******@DotNetM onster.com...
>I have done a program with windows forms in "Visual C++". I have
>implemented a function that returns two values. For example:
>
> double functionExample (int parameter, [Out] double __gc* result2);
>
> And in a header file, I have written this line:
>
> using namespace System::Runtime ::InteropServic es;
>
> This line is necessary for [Out] key word. But when compiling the
> project,
> I get this error:
>
> C:\Program Files\Microsoft Visual Studio .NET
> 2003\Vc7\Platfo rmSDK\Include\W inBase.h(3140): error C2872: 'FILETIME'
> :
> ambiguous symbol could be 'C:\Program Files\Microsoft Visual Studio
> .NET
> 2003\Vc7\Platfo rmSDK\Include\W inDef.h(354) : _FILETIME FILETIME' or
> 'stdafx.cpp(0) : System::Runtime ::InteropServic es::FILETIME'
>
> How can I solve it? Thanks.
>
> --
> Message posted via http://www.dotnetmonster.com



Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3300
by: EHuq | last post by:
Hi there I am facing a problem. When I include my unmanaged header file in my form1.h file, I am facing the compile error with the following messag C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(7408) : error C2872: 'IDataObject' : ambiguous symbo could be 'C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ObjIdl.h(246) : System::Windows::Forms::IDataObject IDataObject or ...
3
2741
by: Lee Gillie | last post by:
I have a VS6 project which I brought into VS .NET, and all has been building fine. Then I upgraded to VS 2003 and I have one source which will no longer compile. Any clues? Compiling... DotNetManagedExport.cpp C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlcom.h(5529) : error C2872: 'CONNECTDATA' : ambiguous symbol could be 'C:\Program Files\Microsoft Visual Studio .NET
0
1812
by: gerry.brennan | last post by:
Hi, I have a project which accesses a database via a database interface class which uses #include microsoft library. In the header file for this database class I have a prototype which passes by reference a CRecordset paramater.
3
7841
by: nicolas.hilaire | last post by:
Hi group, when using unmanaged class with my managed app, I've seen errors when including (for example) <windows.h>. One of theses erros is : IDataObject : ambiguous symbol error I've seen somewhere that to avoid this error, i've to remove all "using namespace XXXXX" from .h, and move it to .cpp.
9
13288
by: Prasad | last post by:
HI, I am a beginner in VC++.. I am trying to write a Win32 console application in visual studio.. I am using following header files.. #include <STRING> using namespace std; #include <hash_map>//from Standard template library //and some other headers
4
4862
by: davidk13 | last post by:
My C++/CLI program uses the WinAPI to create a document, and my use of the Rectangle function--BOOL Rectangle (HDC hDC, int nLeft, int nTOP, int nRight, int nBottom--results in a compiler error C2872-'Rectangle':ambiguous symbol. How can I resolve this ambiguity? Thanks, David
6
16200
by: phnimx | last post by:
I'm attempting to migrate a predominately MFC application that I've just inherited from Visual Studio.NET 2003 to Visual Studio 2005. I've managed to clean up a myriad of compile and link errors but I'm stuck on one final problem. Please note that this application compiled/linked and ran just fine out of Visual Studio.NET 2003. Details: It's originally incarnated as an MFC app, i.e. CWinApp, CMultiDocTemplate,
3
8233
by: kartik369 | last post by:
hi while compiling my code im getting these errors: C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinBase.h(4729): error C2872: 'FILETIME' : ambiguous symbol could be 'C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinDef.h(354) : _FILETIME FILETIME' or 'stdafx.cpp(0) : System::Runtime::InteropServices::FILETIME' can anyone let me know how to resolve this...
0
2346
by: dakshayini | last post by:
Hi, I have created one project in Visual studio 2005. For my application i need to put Sleep() function.n i have added the #include <windows.h> Now if i run this i am getting error as' IServiceProvider' : ambiguous symbol Please if any one knows about this let me know.. Actually i have created in one more project with single form n if i include this sleep function it is running properly..if i put the same in my Application i am...
0
9990
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11250
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10850
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10941
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8032
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7185
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4698
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.