Ambiguous symbol error

  • Thread starter rodri rodri via DotNetMonster.com
  • Start date
R

rodri rodri via DotNetMonster.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::InteropServices;

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\PlatformSDK\Include\WinBase.h(3140): 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'

How can I solve it? Thanks.
 
S

Steve McLellan

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

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
 
G

Guest

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::InteropServices;"
And "Form1.cpp" has this line: "#include <windows.h>

/*File1.h*/

#pragma once

using namespace System::Runtime::InteropServices;

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(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;
Application::Run(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 said:
You could try using:
#undef FILETIME
using namespace System::Runtime::InteropServices;

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.com said:
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::InteropServices;

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\PlatformSDK\Include\WinBase.h(3140): 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'

How can I solve it? Thanks.
 
S

Steve McLellan

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::InteropServices

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 said:
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::InteropServices;"
And "Form1.cpp" has this line: "#include <windows.h>

/*File1.h*/

#pragma once

using namespace System::Runtime::InteropServices;

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(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;
Application::Run(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 said:
You could try using:
#undef FILETIME
using namespace System::Runtime::InteropServices;

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.com said:
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::InteropServices;

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\PlatformSDK\Include\WinBase.h(3140): 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'

How can I solve it? Thanks.
 
L

Larry Brasfield

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: (e-mail address removed)
Above views may belong only to me.

Steve McLellan said:
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::InteropServices

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 said:
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::InteropServices;"
And "Form1.cpp" has this line: "#include <windows.h>

/*File1.h*/

#pragma once

using namespace System::Runtime::InteropServices;

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(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;
Application::Run(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 said:
You could try using:
#undef FILETIME
using namespace System::Runtime::InteropServices;

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

message 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::InteropServices;

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\PlatformSDK\Include\WinBase.h(3140): 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'

How can I solve it? Thanks.
 
S

Steve McLellan

Hi,

My apologies.

Steve

Larry Brasfield said:
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: (e-mail address removed)
Above views may belong only to me.

Steve McLellan said:
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::InteropServices

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 said:
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::InteropServices;"
And "Form1.cpp" has this line: "#include <windows.h>

/*File1.h*/

#pragma once

using namespace System::Runtime::InteropServices;

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(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState =
System::Threading::ApartmentState::STA;
Application::Run(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"


----------------------------------------------------------
:

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

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

message 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::InteropServices;

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\PlatformSDK\Include\WinBase.h(3140): 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'

How can I solve it? Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top