Home > Software engineering >  Compiler error c2237 when working with modules
Compiler error c2237 when working with modules

Time:10-04

I am trying to change a project to use modules in visual studio. I have changed a simple class to generate a module as follows:

#pragma once

export module FieldData;

namespace Serializer
{
    class FieldData
    {
    public:
        bool nvConverted{ false };
    };
}

I've also changed the item type to 'c/c compiler' This results in the following error however:

error C2237: multiple module declaration

Unfortunately there seems to be no documentation on what causes c2237 or how to resolve it

CodePudding user response:

I figured it out. The problem was that I hadn't changed the 'Compile as' option in the project properties -> Configuration properties -> C/C -> Advanced. The value it needs to be is: 'Compile as C Module Code (/interface )'

  • Related