0

これは私のプログラムの 2 番目のフォームであり、上記のエラーが発生します。コンストラクター関数がエラーを生成するものであり、その理由はわかりません。これは、私のメイン ウィンドウのコンストラクターとほぼ同じで、問題なく動作します。

唯一の違いは、これが引数を取ることです。(SettingsForm コンストラクターの引数を削除して に戻してvoidも、同じエラーが発生します。

このコンストラクターがアンマネージ関数としてコンパイルされていると思われる理由を誰か教えてもらえますか?

SettingsForm.h

#pragma once
#pragma managed(push, off)
#include "SpriteyData.h"
#pragma managed(pop)

namespace Spritey {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    using namespace SpriteyData;

    /// <summary>
    /// Summary for SettingsForm
    /// </summary>
    public ref class SettingsForm : public System::Windows::Forms::Form
    {

    public:
        SpriteySettings* currentSetLocCopy;//A local copy of our current settings.

        SettingsForm(SpriteySettings* currentSettings)<------ERROR OCCURS HERE
        {
            InitializeComponent();

            currentSetLocCopy = new SpriteySettings(*currentSettings); //take a copy of our current settings
            //initialise the elements on our form to the values stored in the SpriteySettings
            this->anchorDevCheckBox->Checked = currentSetLocCopy->isAnchorDevAllowed();
        }



    protected:
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        ~SettingsForm()
        {
            if (components)
            {
                delete components;

            }
            if(currentSetLocCopy)
            {
                delete currentSetLocCopy;
            }
        }
    private: System::Windows::Forms::Button^  CancelButton;
    private: System::Windows::Forms::Button^  ApplyButton;
    private: System::Windows::Forms::GroupBox^  editorSettingsGroup;
    private: System::Windows::Forms::CheckBox^  anchorDevCheckBox;
    private:

注:上記は単なるコンストラクタ + もう少しのコードであり、エラーの原因となっている部分のコード サンプルにすぎません。

また、これは管理されたプロジェクトと管理されていないプロジェクトが混在しています。

4

2 に答える 2

4

このコンパイル エラーの再現:

#pragma managed(push, off)
class SpriteySettings {};

ref class Test
{
public:
    Test(SpriteySettings* arg) {}
};

エラー C3280: 'Test::Test': マネージド型のメンバー関数はアンマネージド関数としてコンパイルできません

追加のエラーのスルーだけでなく。したがって、診断は、このコードが/clr コンパイル オプションを有効にせずにコンパイルされていることです。これは .h ファイルであるため、/clr なしでコンパイルされている .cpp ファイルに #include したことが原因である可能性があります。その #include ディレクティブを見つける必要があります。

于 2013-10-04T16:35:19.543 に答える