I have a C# project with 2 function
namespace LibiqCommonStructures
{
public class BlackLevelData : List<BlackLevelLookupTable>
{
public BlackLevelData()
{
}
public BlackLevelData(BlackLevelData original)
: base(original.DeepCopy())
{
}
public void AddLookupTable(double gain, double exposure, double[] levels)
{
var table = new BlackLevelLookupTable
{
AnalogGain = gain,
ExposureTime = exposure,
ChannelLevels = levels
};
Add(table);
}
}
}
same for SaturationLevelData
I created a c++\\CLI project and I want to give the two class into a function as parameters
#pragma once
#include "Preprocessor.h"
using namespace LibiqCommonStructures;
namespace ToolBox {
public ref class PreprocessorWrapper
{
public:
PreprocessorWrapper();
void Function1(BlackLevelData^ blackLevelData, SaturationLevelData^ saturationLevelData);
private:
Preprocessor* _preprocessor;
};
}
header
#include "PreprocessorWrapper.h"
void ToolBox::PreprocessorWrapper::Function1(BlackLevelData^ blackLevelData, SaturationLevelData^ saturationLevelData)
{
_preprocessor->Function1();
}
ToolBox::PreprocessorWrapper::PreprocessorWrapper()
{
_preprocessor = new Preprocessor();
}
here are the errors I get
Error 2 error C2871: 'LibiqCommonStructures' : a namespace with this name does not exist g:\iqtool2\src\libiqtool\preprocessor_interop\PreprocessorWrapper.h 5 1 Preprocessor_interop
Error 8 error C2448: 'ToolBox::PreprocessorWrapper::Function1' : function-style initializer appears to be a function definition G:\IQTool2\src\libiqtool\Preprocessor_interop\PreprocessorWrapper.cpp 5 1 Preprocessor_interop
Error 6 error C2065: 'SaturationLevelData' : undeclared identifier G:\IQTool2\src\libiqtool\Preprocessor_interop\PreprocessorWrapper.cpp 4 1 Preprocessor_interop
Error 7 error C2065: 'saturationLevelData' : undeclared identifier G:\IQTool2\src\libiqtool\Preprocessor_interop\PreprocessorWrapper.cpp 4 1 Preprocessor_interop
Error 4 error C2065: 'BlackLevelData' : undeclared identifier G:\IQTool2\src\libiqtool\Preprocessor_interop\PreprocessorWrapper.cpp 4 1 Preprocessor_interop
Error 5 error C2065: 'blackLevelData' : undeclared identifier G:\IQTool2\src\libiqtool\Preprocessor_interop\PreprocessorWrapper.cpp 4 1 Preprocessor_interop
Error 3 error C2061: syntax error : identifier 'BlackLevelData' g:\iqtool2\src\libiqtool\preprocessor_interop\PreprocessorWrapper.h 13 1 Preprocessor_interop
Can you see what I did wrong here?
First, make sure you are building your C++ project with the /clr switch. It is strange you are not referencing at least the System assembly.
Second, the screenshot you provided seems to indicate that your C++/CLI project is using the .NET Framework v4.0. Assuming your C# project is using the .NET Framework v4.5, try updating your C++/CLI project to match. You can hand-edit the project file (.vcxproj) as follows:
<PropertyGroup Label="Globals">
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
I reproduced your issue by changing the version to v4.0 with Visual Studio 2013.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.