Ошибка C2976 'std :: array': слишком мало аргументов шаблона и других после миграции на VS 2019 - PullRequest
0 голосов
/ 05 февраля 2020

Я получаю следующие ошибки при попытке скомпилировать файл c ++ в Visual Studio 2019. Разработчик, создавший программное обеспечение, говорит, что он работал на Visual Studio 2012.

Я получаю следующую ошибку:

Severity    Code    Description Project File    Line    Suppression State
Error   C2976   'std::array': too few template arguments    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 45  
Error   C3699   '^': cannot use this indirection on type 'std::array'   CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 45  
Error   C2976   'std::array': too few template arguments    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 45  
Error   C2027   use of undefined type 'std::array'  CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 45  
Error   C2976   'std::array': too few template arguments    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 46  
Error   C3699   '^': cannot use this indirection on type 'std::array'   CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 46  
Error   C2976   'std::array': too few template arguments    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 46  
Error   C2027   use of undefined type 'std::array'  CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 46  
Error   C2976   'std::array': too few template arguments    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 47  
Error   C3699   '^': cannot use this indirection on type 'std::array'   CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 47  
Error   C2976   'std::array': too few template arguments    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 47  
Error   C2027   use of undefined type 'std::array'  CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 47  
Error   C2976   'std::array': too few template arguments    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 49  
Error   C3699   '^': cannot use this indirection on type 'std::array'   CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 49  
Error   C2976   'std::array': too few template arguments    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 49  
Error   C2027   use of undefined type 'std::array'  CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 49  
Error   C2976   'std::array': too few template arguments    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 50  
Error   C3699   '^': cannot use this indirection on type 'std::array'   CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 50  
Error   C2976   'std::array': too few template arguments    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 50  
Error   C2027   use of undefined type 'std::array'  CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 50  
Error   C2582   'operator =' function is unavailable in 'std::array'    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 52  
Error   C2582   'operator =' function is unavailable in 'std::array'    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 53  
Error   C2582   'operator =' function is unavailable in 'std::array'    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 54  
Error C2664 'void CalculatorLibrary::ExternalInterface::AddHubInformationv                    (int,cli::array<double,1> ^,cli::array<System::String ^,1> ^,cli::array<System::String ^,1> ^)': cannot  convert argument 2 from 'std::array *' to 'cli::array<double,1> ^'   CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 57  
Error   C2976   'std::array': too few template arguments    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 76  
Error   C3699   '^': cannot use this indirection on type 'std::array'   CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 76  
Error   C2976   'std::array': too few template arguments    CalculatorsAIMMSInterop C:\DELTA\NDHCalculators\Development\CalculatorsAIMMSInterop\CalculatorsAIMMSInterop.cpp 76  

Вот код, который не работает:

#include "stdafx.h"
#include <msclr/marshal.h>
#include "CalculatorsAIMMSInterop.h"

using namespace msclr::interop;
using namespace System;
using namespace System::Reflection;
using namespace std;

void marshalString(System::String^ input, char* output)
{
    //marshal_context ^ context = MarshalContextSingleton::GetInstance();
    marshal_context ^ context = gcnew marshal_context();
    const char* strResult = context->marshal_as<const char*>(input);
    strcpy(output, strResult);
    delete context;
}

void marshalInt(System::Int32 input, char* output) 
{
    //marshal_context ^ context = MarshalContextSingleton::GetInstance();
    marshal_context ^ context = gcnew marshal_context();
    const char* strResult = context->marshal_as<const char*> (""+input);
    strcpy(output, strResult);
    delete context;
}

System::String^ marshalString(char* input)
{
    //marshal_context ^ context = MarshalContextSingleton::GetInstance();
    marshal_context ^ context = gcnew marshal_context();
    System::String^ output = context->marshal_as<System::String^>(input);
    delete context;
    return output;
}

// Methods for hub activity calculator
void WINAPI HubActivityInitialize(int calenderStart, int calendarEnd) {
    CalculatorLibrary::ExternalInterface::InitializeHubActivityCalculator(calenderStart, calendarEnd);
}

void WINAPI HubActivityAddInformation(int numberOfValues, double* activities, char** arrivalTimes, char** departureTimes) {
    array<double>^ activitiesDoubles = gcnew array<double>(numberOfValues);
    array<String^>^ arrivalTimeStrs = gcnew array<String^>(numberOfValues);
    array<String^>^ departureTimeStrs = gcnew array<String^>(numberOfValues);

    array<int>^ arrivalTimeInts = gcnew array<int>(numberOfValues);
    array<int>^ departureTimeInts = gcnew array<int>(numberOfValues);
    for (int i = 0; i < numberOfValues; i++) {
        activitiesDoubles[i] = activities[i];
        arrivalTimeStrs[i] = marshalString(arrivalTimes[i]);
        departureTimeStrs[i] = marshalString(departureTimes[i]);
    }

    CalculatorLibrary::ExternalInterface::AddHubInformation(numberOfValues, activitiesDoubles, arrivalTimeStrs, departureTimeStrs);
}

void WINAPI HubActivityGet(double* amounts) {
    System::Collections::Generic::List<double>^ hubActivityAmounts = CalculatorLibrary::ExternalInterface::GetHubActivity();
    for(int i = 0; i < hubActivityAmounts->Count; i++ )
    {
        amounts[i] = hubActivityAmounts[i];
    }
}

void WINAPI HubActivityReset() {
    CalculatorLibrary::ExternalInterface::ResetHubActivity();
}

// Methods for conveying calculator
void WINAPI ConveyingInitialize(int start, int end, char** startedConveyingQuantity) {
    int numberOfValues = end - start + 1;

    array<String^>^ quantity = gcnew array<String^>(numberOfValues);
    for (int i = 0; i < numberOfValues; i++) {
        quantity[i] = marshalString(startedConveyingQuantity[i]);
    }

    CalculatorLibrary::ExternalInterface::InitializeConveyingCalculator(start, end, quantity);
}

void WINAPI ConveyingAddPieceInformation(int numberOfPieces, char** inMovementsIds) {
    array<String^>^ incomingMovementIds = gcnew array<String^>(numberOfPieces);

    for (int i = 0; i < numberOfPieces; i++) {
        incomingMovementIds[i] = marshalString(inMovementsIds[i]);
    }

    CalculatorLibrary::ExternalInterface::AddConveyingPieceInformation(numberOfPieces, incomingMovementIds);
}

void WINAPI ConveyingAddConnectionInformation(int numberOfConnections, char** inMovementsIds, char** outMovementsIds, char** numberOfConnectedPieces) {
    array<String^>^ incomingMovementIds = gcnew array<String^>(numberOfConnections);
    array<String^>^ outgoingMovementIds = gcnew array<String^>(numberOfConnections);
    array<String^>^ connectedPieces = gcnew array<String^>(numberOfConnections);

    for (int i = 0; i < numberOfConnections; i++) {
        incomingMovementIds[i] = marshalString(inMovementsIds[i]);
        outgoingMovementIds[i] = marshalString(outMovementsIds[i]);
        connectedPieces[i] = marshalString(numberOfConnectedPieces[i]);
    }

    CalculatorLibrary::ExternalInterface::AddConveyingConnectionInformation(incomingMovementIds, outgoingMovementIds, connectedPieces);
}

void WINAPI ConveyingRunCalculation() {
    CalculatorLibrary::ExternalInterface::RunConveyingCalculation();
}

void WINAPI ConveyingResultGet(char** pieceMovementIDOut, char** pieceTimeAtConveyor) {
    array<int>^ pieceOutgoingMovement = CalculatorLibrary::ExternalInterface::GetPieceOutgoingMovement();
    array<int>^ pieceConveyorEntryTime = CalculatorLibrary::ExternalInterface::GetPieceConveyorEntryTime();

    for(int i = 0; i < pieceOutgoingMovement->Length; i++ )
    {
        marshalInt(pieceOutgoingMovement[i], pieceMovementIDOut[i]);
        marshalInt(pieceConveyorEntryTime[i], pieceTimeAtConveyor[i]);
    }
}

void WINAPI ConveyingReset() {
    CalculatorLibrary::ExternalInterface::ResetConveying();
}

// Methods for conveying calculator via text files
void WINAPI ConveyingInitializeFromFile(char* filePath) {
    String^ path = marshalString(filePath);
    CalculatorLibrary::ExternalInterface::InitializeConveyingCalculator(path);
}

void WINAPI WriteConveyingCalculationToFile(char* filePath) {
    String^ path = marshalString(filePath);
    CalculatorLibrary::ExternalInterface::WriteConveyingCalculatorData(path);
}

// Methods for Route Generation
void WINAPI InitializeCaseWithLogging(char* logfile_name) {
    RouteGeneration::IO::ExternalInterface::Initialize(marshalString(logfile_name));
}

int WINAPI GetRouteGenerationInputErrorCount() {
    return RouteGeneration::IO::ExternalInterface::CloseErrorLogAndRetrieveErrorCount();
}

void WINAPI RouteGenerationInitializeFromFiles(char* filePath1, char* filePath2, char* errorMessage) {
    String^ path1 = marshalString(filePath1);
    String^ message1 = RouteGeneration::IO::ExternalInterface::ReadNetworkModelInformation(path1);

    if (message1 != "OK") {
        marshalString(message1, errorMessage);
        return;
    }

    String^ path2 = marshalString(filePath2);
    String^ message2 = RouteGeneration::IO::ExternalInterface::ReadRouteGenerationRequests(path2);

    marshalString(message2, errorMessage);
}

void WINAPI RunRouteGeneration() {
    RouteGeneration::IO::ExternalInterface::GenerateRoutes();
}

void WINAPI RunAllToAllRouteGeneration(char* modelDataFilePath, char* requestDataFilePath, char* databaseFilePath, char* errorMessage) {
    String^ modelDataPath = marshalString(modelDataFilePath);
    String^ requestDataPath = marshalString(requestDataFilePath);
    String^ databasePath = marshalString(databaseFilePath);

    String^ message = RouteGeneration::IO::ExternalInterface::ReadAndGenerateAllToAllRoutes(modelDataPath, requestDataPath, databasePath);
    marshalString(message, errorMessage);
}

void WINAPI WriteGeneratedRoutesToFile(char* filePath, char* errorMessage) {
    String^ path = marshalString(filePath);
    String^ message = RouteGeneration::IO::ExternalInterface::WriteGeneratedRoutes(path);

    marshalString(message, errorMessage);
}

void WINAPI RouteGenerationReset() {
    RouteGeneration::IO::ExternalInterface::CleanMemory();
}

// Methods for Hub Simulation
void WINAPI InitializeSimulationCaseWithLogging(char* logfile_name) {
    HubSimulation::IO::ExternalInterface::Initialize(marshalString(logfile_name));
}

int WINAPI GetHubSimulationInputErrorCount() {
    return HubSimulation::IO::ExternalInterface::CloseErrorLogAndRetrieveErrorCount();
}

void WINAPI HubSimulationInitializeFromFiles(char* filePath1, char* filePath2, char* errorMessage) {
    String^ path1 = marshalString(filePath1);
    String^ message1 = HubSimulation::IO::ExternalInterface::ReadHubSimulationModelInformation(path1);

    if (message1 != "OK") {
        marshalString(message1, errorMessage);
        return;
    }

    String^ path2 = marshalString(filePath2);
    String^ message2 = HubSimulation::IO::ExternalInterface::ReadPiecesInformation(path2);

    marshalString(message2, errorMessage);
}

void WINAPI RunHubSimulation() {
    HubSimulation::IO::ExternalInterface::RunSimulation();
}

void WINAPI WriteHubSimulationResultsToFile(char* filePath, char* errorMessage) {
    String^ path = marshalString(filePath);

    String^ message = HubSimulation::IO::ExternalInterface::WriteSimulationResults(path);
    marshalString(message, errorMessage);
}

void WINAPI HubSimulationReset() {
    HubSimulation::IO::ExternalInterface::CleanMemory();
}

1 Ответ

1 голос
/ 05 февраля 2020

Почему Visual Studio Express 2012 недоступен для загрузки?

Есть. Погуглив "visual studio express 2012 download", вы попадете прямо на https://visualstudio.microsoft.com/vs/older-downloads, откуда вы можете загрузить приложение. программное обеспечение не решит вашу проблему. Вы не показали нам код или не сказали, какой компилятор вы используете (очевидно, это не Visual Studio 2012; он старше? Новее?). Но маловероятно, чтобы ошибка «слишком мало аргументов шаблона» из std::array была исправлена ​​изменением версии.

Ошибка предполагает, что передается std::array *; это вещь, которой не существует. Нет типа std::array; Существуют только шаблоны специализаций, такие как std::array<T, N>.

Вы должны попросить автора уточнить, потому что это похоже на ошибку кода. Затем, вместо устаревшего программного обеспечения, выберите самую последнюю версию Visual Studio.


Также C# - это нечто другое. Предположительно проект содержит C#, а затем этот код C ++ / CLI в качестве уровня взаимодействия. Но C# не имеет отношения к вашему вопросу и вашей проблеме.

...