Announcement

Collapse
No announcement yet.

Suddenly unable to add c++ classes

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Suddenly unable to add c++ classes

    Since upgrading to 4.23, we are getting compile errors inOnlySubsystemTypes.h when we attempt to add C++ classes to the project. We have tried adding them through the editor as well as through the Visual Studio project. Both routes yield the same errors. We have also tried doing a full recompile from VisualStudio with the editor closed:

    [2019.11.13-22.00.35:438][ 3]CompilerResultsLog: Reflection code generated for NovusEditor in 47.194904 seconds
    [2019.11.13-22.00.35:438][ 3]CompilerResultsLog: [Adaptive unity build] Excluded from Novus unity file: NovusPlayerCameraManager.cpp, UFireModeComponent.cpp
    [2019.11.13-22.00.35:438][ 3]CompilerResultsLog: Using Visual Studio 2017 14.16.27023 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023) and Windows 10.0.17763.0 SDK (C:\Program Files (x86)\Windows Kits\10).
    [2019.11.13-22.00.35:438][ 3]CompilerResultsLog: Building 6 actions with 16 processes...
    [2019.11.13-22.00.35:438][ 3]CompilerResultsLog: [1/6] NovusPlayerCameraManager.cpp
    [2019.11.13-22.00.35:438][ 3]CompilerResultsLog: [2/6] Module.Novus.cpp
    [2019.11.13-22.00.35:438][ 3]CompilerResultsLog: d:\novusp4\depot\ue_4.23_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1374) : error C2143: syntax error: missing ')' before 'constant'
    [2019.11.13-22.00.35:439][ 3]CompilerResultsLog: d:\novusp4\depot\ue_4.23_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1374) : error C2143: syntax error: missing ';' before 'constant'
    [2019.11.13-22.00.35:439][ 3]CompilerResultsLog: d:\novusp4\depot\ue_4.23_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1374) : error C2059: syntax error: 'constant'
    [2019.11.13-22.00.35:439][ 3]CompilerResultsLog: d:\novusp4\depot\ue_4.23_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1374) : error C2059: syntax error: ')'
    [2019.11.13-22.00.35:439][ 3]CompilerResultsLog: d:\novusp4\depot\ue_4.23_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1374) : error C2143: syntax error: missing ';' before '{'
    [2019.11.13-22.00.35:440][ 3]CompilerResultsLog: d:\novusp4\depot\ue_4.23_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1374) : error C2447: '{': missing function header (old-style formal list?)
    [2019.11.13-22.00.35:440][ 3]CompilerResultsLog: d:\novusp4\depot\ue_4.23_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1374) : error C2059: syntax error: '}'
    [2019.11.13-22.00.35:440][ 3]CompilerResultsLog: [3/6] Module.Novus.gen.cpp
    [2019.11.13-22.00.35:440][ 3]LogMainFrame: MainFrame: Module compiling took 82.691 seconds
    [2019.11.13-22.00.35:440][ 3]Warning: HotReload failed, recompile failed
    [2019.11.13-22.00.35:447][ 3]Warning: RebindPackages failed because compilation failed.
    [2019.11.13-22.00.44:375][ 3]LogSlate: Window 'Message' being destroyed
    [2019.11.13-22.00.44:382][ 3]LogSlate: Window 'Add C++ Class' being destroyed

    #2
    I have not had this exact error, but I have had strange ones like this where it is complaining about syntax issues in the engine. Somewhere in my code I forgot a { or (. Nowhere indicated by any kind of error message.

    I had to scan my recent changes to find it.

    Comment


      #3
      Thanks for the reply acxsasx. However, I do not think this is the case in this instance. The project compiles and runs just fine until I use the editor to add a very basic class. Here is the class generated by the editor:

      .H file:
      Code:
      // Fill out your copyright notice in the Description page of Project Settings.
      
      #pragma once
      
      #include "CoreMinimal.h"
      
      /**
      *
      */
      class NOVUS_API NovusPlayerCameraManager
      {
      public:
      NovusPlayerCameraManager();
      ~NovusPlayerCameraManager();
      };
      CPP:
      Code:
      // Fill out your copyright notice in the Description page of Project Settings.
      
      
      #include "NovusPlayerCameraManager.h"
      
      NovusPlayerCameraManager::NovusPlayerCameraManager()
      {
      }
      
      NovusPlayerCameraManager::~NovusPlayerCameraManager()
      {
      }

      Comment


        #4
        1) don't use hot reload if you're adding or modifying classes.
        2) I can't tell what the problem is without seeing your class header code or a simplified class which reproduces the problem
        3) Are you classes inheriting from the right base class?

        Comment


          #5
          Originally posted by J McBride View Post
          Thanks for the reply acxsasx. However, I do not think this is the case in this instance. The project compiles and runs just fine until I use the editor to add a very basic class. Here is the class generated by the editor:

          .H file:
          Code:
          // Fill out your copyright notice in the Description page of Project Settings.
          
          #pragma once
          
          #include "CoreMinimal.h"
          
          /**
          *
          */
          class NOVUS_API NovusPlayerCameraManager
          {
          public:
          NovusPlayerCameraManager();
          ~NovusPlayerCameraManager();
          };
          CPP:
          Code:
          // Fill out your copyright notice in the Description page of Project Settings.
          
          
          #include "NovusPlayerCameraManager.h"
          
          NovusPlayerCameraManager::NovusPlayerCameraManager()
          {
          }
          
          NovusPlayerCameraManager::~NovusPlayerCameraManager()
          {
          }
          Strange. I don't see the UCLASS() macro. I don't see that you have selected any class to inherit from. As Slayemin has said, don't be adding classes (and I would add changing any methods of existing classes) during a hot reload. If I am changing code internal to an existing method, I will utilize hotreload. If I change a property or method's signature in any way, I close down the editor.

          I build the engine from source. I use a private/public structure for my C++ files.

          I have successfully added C++ classes using the following:

          In order to add a C++ class from your project follow the steps below:
          1. Close Visual Studio
          2. Close UE4 Editor
          3. Add the corresponding .cpp and .h files to the private and public folders respectively
          4. Right click the .uproject file and click Generate Visual Studio project Files

          Comment


            #6
            Thanks again for the help! It is very strange that the Editor is leaving out the UCLASS() Macro. I intentionally was not inheriting from a class to keep it as basic as possible to try and debug what the problem was. (We originally thought the issue was being caused by inheriting from Unreal classes, but it turned out that attempting to add any class causes this.)

            I tried following your steps as well, and get the same result:
            1. Closed VS & The Editor (even rebooted to ensure no Unreal processes were running.)
            2. Added AFubar.h to public folder and AFubar.cpp to private folder. (We're not using this directory structure, but I wanted to rule it out as the bug.)
            3. Genereated Visual Studio Project files from the .uproject.

            For this test, I duplicated a previous class that I added back on 4.21 that compiles just fine currently in 4.23 and just changed the name. I wanted to confirm that your success with adding classes in on 4.23? That seems to be the only thing that has change since both creating classes in the editor and creating classes manually stopped working for us.

            Code:
            // Fill out your copyright notice in the Description page of Project Settings.
            
            #pragma once
            
            #include "CoreMinimal.h"
            #include "AItemBase.h"
            
            #include "AFubar.generated.h"
            
            /**
             * 
             */
            UCLASS()
            class NOVUS_API AFubar : public AItemBase
            {
                GENERATED_BODY()
            
            };
            Code:
            // Fill out your copyright notice in the Description page of Project Settings.
            
            
            #include "AFubar.h"

            Comment


              #7
              Actually, just to check it, I went back to 4.22.2 and I'm getting the same thing. One thing that I notice in the output log is that the AFubar.cpp is being excluded from the Novus unity file? Not sure what that means though:

              1>------ Build started: Project: Novus, Configuration: Development_Editor x64 ------
              1>Creating makefile for ShaderCompileWorker (no existing makefile)
              1>Creating makefile for NovusEditor (no existing makefile)
              1>Creating makefile for UnrealHeaderTool (no existing makefile)
              1>Parsing headers for NovusEditor
              1> Running UnrealHeaderTool "D:\NovusP4\depot\Novus\Novus.uproject" "D:\NovusP4\depot\Novus\Intermediate\Build\Win64\NovusEditor\Development\NovusEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors
              1>Reflection code generated for NovusEditor in 5.8422226 seconds
              1>[Adaptive unity build] Excluded from Novus unity file: AFubar.cpp, UFireModeComponent.cpp
              1>Using Visual Studio 2017 14.16.27023 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023) and Windows 10.0.17763.0 SDK (C:\Program Files (x86)\Windows Kits\10).
              1>Building 6 actions with 16 processes...
              1> [1/6] AFubar.cpp
              1> [2/6] Module.Novus.cpp
              1>d:\novusp4\depot\ue_4.22.2_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1368): error C2143: syntax error: missing ')' before 'constant'
              1>d:\novusp4\depot\ue_4.22.2_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1368): error C2143: syntax error: missing ';' before 'constant'
              1>d:\novusp4\depot\ue_4.22.2_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1368): error C2059: syntax error: 'constant'
              1>d:\novusp4\depot\ue_4.22.2_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1368): error C2059: syntax error: ')'
              1>d:\novusp4\depot\ue_4.22.2_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1368): error C2143: syntax error: missing ';' before '{'
              1>d:\novusp4\depot\ue_4.22.2_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1368): error C2447: '{': missing function header (old-style formal list?)
              1>d:\novusp4\depot\ue_4.22.2_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1368): error C2059: syntax error: '}'
              1> [3/6] Module.Novus.gen.cpp
              1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command "D:\NovusP4\depot\UE_4.22.2_Editor\Engine\Build\BatchFiles\Build.bat -Target="ShaderCompileWorker Win64 Development" -Target="NovusEditor Win64 Development -Project="D:\NovusP4\depot\Novus\Novus.uproject"" -WaitMutex -FromMsBuild" exited with code 5. Please verify that you have sufficient rights to run this command.
              1>Done building project "Novus.vcxproj" -- FAILED.
              ========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========

              Comment


                #8
                It's tied to the number of classes somehow:
                1. Remove arbitrary class: compiles fine
                2. Add AFubar class: compiles fine
                3. Add ANewFubar class:
                  3>d:\novusp4\depot\ue_4.23_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1374): error C2143: syntax error: missing ')' before 'constant'
                  3>d:\novusp4\depot\ue_4.23_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1374): error C2143: syntax error: missing ';' before 'constant'
                  3>d:\novusp4\depot\ue_4.23_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1374): error C2059: syntax error: 'constant'
                  3>d:\novusp4\depot\ue_4.23_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1374): error C2059: syntax error: ')'
                  3>d:\novusp4\depot\ue_4.23_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1374): error C2143: syntax error: missing ';' before '{'
                  3>d:\novusp4\depot\ue_4.23_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1374): error C2447: '{': missing function header (old-style formal list?)
                  3>d:\novusp4\depot\ue_4.23_editor\engine\plugins\online\onlinesubsystem\source\public\OnlineSubsystemTypes.h(1374): error C2059: syntax error: '}'
                4. Delete AFubar class: compiles fine with ANewFubar class still included.

                Comment


                  #9
                  I have found the cause/solution: Adaptive Unity. When adding a class, the *.init.gen.cpp files were not being properly generated. Adding bUseUnityBuild = false; to all of our target.cs files resolved the issue.

                  Comment


                    #10
                    Thanks for posting an update. It's working fine for me in 4.22. I am planning on skipping 4.23.

                    Comment

                    Working...
                    X