Cabbage Logo
Back to Cabbage Site

Compilation error in VS2019 from "cabbageCopyFile" new opcode

Hello,

I tried to compile Cabbage from the develop branch, but I’m getting stuck with a weird compilation error in VS2019 :

(sorry it’s in French, but it’s basically :

  • Error C2332: ‘class’ : missing tag name
  • Error C2059: syntax error ‘constant’
  • Error C2913: explicit specialization; (declaration) is not a specialization of a class template

So I investigated (git bissect) and I found it started from this commit :

I don’t have any compiling issues with the previous commits.

After some trial & error, I removed everything related to this new opcode and it worked again…
So, I tried in CabbageIdentifierOpcode.cpp to add the #include "filesystem.hpp"


(like this, but I uncommented it)

=> Compilation error

After investigating through this .hpp, I deleted everything and started to add the includes one by one…

I found that the compilation error is caused by #include <chrono>
image

=> When I remove it, it compiles again…

So that’s where I am… A bit stuck, because for now I can build, but I really wanted to test this new opcode !

I am using Windows 10, VS2019 (v16.2.0), Windows SDK 10.0

I think it’s VS compiler doing some funny stuff, because @rorywalsh Azure DevOps build works great, so thanks in advance your help !

Let me know if you need some more details.

Are you trying to build from the latest devs, or that commit specifically? Btw, I’m moving this to the Cabbage Farmers category which is better suited for this kind of discussion :wink:

I tried first to build from the recent commit where you added SVGelement, and when I saw it failed, I went back with git bissect to find the commit responsible of this

Thanks for moving this conv to the right section :wink:

Probably best to stick with the most recent one deb branch. As for the problem here, I’m not entirely sure why it fails for you.

On the other hand, if it’s compiling without it I’d say you’re good to go. I didn’t write that filesystem header, it’s just there to provide an interface to goodies provided in newer versions of C++.

[edit] I just tried now and the opcode still works fine :+1:

1 Like

Ah okay ! I though it was required !
It works for me but I completely deleted the opcode… How did you manage to make it work ? Did you just remove the header to the .cpp file ?

Reclone the latest dev tip. Then open filesystem.hpp, in the Source/Opcodes folder and comment out line 194. :+1:

I tried this, and now I have 96 errors… It’s complaining about chrono basically… (Here are some errors, not all the errors but the other are the same as these ones)

I don’t get how this can work without the chrono header, because some chrono functions are used in the code :thinking:

You said you had already done this? I tried it too, and it compiled fine without chrono? I can try Windows in a moment, I’m on a Mac right now.

I just tested and it builds fine for me on Windows too if I comment out chrono. :thinking:

Do your language settings say C++14?

I did, but in this order :

  1. Clone the repo
  2. Compile => Failed
  3. Removed the CabbageCopyFile function from CabbageIdentifierOpcodes.cpp (+ the reference of it in CsoundPluginProcessor.cpp)
  4. Compile => Failed again
  5. Remove everything in the .hpp, but left this only
    image
    (so there is no more code in this file now, just few headers)
  6. Compiles => Failed again
  7. Removed the include of chrono
  8. Compiles => Worked ! (but : it don’t have any trace of the new opcode now, because of the prior steps I explained…)

I tried again, from scrtach, to make sure I don’t miss something :

  1. clone the repo (latest commit is yesterday from you, and you actuelly already commented out the chrono header in the .hpp)
  2. Opens the projucer of CabbageIDE and export as VS project
  3. In VS,check the settings :
  • C++14 was already selected
  1. Compiles => Failed with the errors I posted few messages above

I think there is an issue with my build environement but I can’t figure out what… It should work, as you tried and it works for you

It looks like it. Can you open the visual studio installer and see if there are newer Windows SDKs that you can install?

Here are the C++ tools I have installed:

The tabs on the right of each picture show the various SDKs and other things that I have installed here.

Thanks ! I’m trying to see if I can use the chrono lib something else, in a hello word project, and yes, it works, I get the same output as here (no compilation error)
So it must be something in the project that my compiler doesn’t like…

So I tried to unistall every VS component and reinstall as you show in the screenshots, but still, I get this compilation error when I try to compile the Cabbage solution…

Try using the filesystem.hpp file instead of the chrono directly as it is the reason chrono is being used at all. I assume when you create a new project that it automatically uses C++17? In which case I think there shouldn’t be any issues.

Can you try adding

using namespace std::chrono;

after you include chrono in the filesystem.hpp file? I really can’y what else could be different with our setups?

So, I tried to add using namespace std::chrono; but without luck… Same errors…

I tried to create a new GUI app from JUCE, to kind of copy Cabbage structure, and I added the chrono header : it built without errors

But when I try the same in the Cabbage solution, in Cabbage.cpp : errors…

So, it’s really weird… Now I know it’s not related to my computer / VS
It’s more something in the Solution that my VS can’t understand maybe, really I have no ideas what’s going on

I read that the include can’t just be included anywhere. It has to be included after other headers. The weird thing is that it’s all from the filesystem.hpp file, which is a well known interface. Try replacing all instances of
ghc::filesystem
with
std::filesystem

But note you will also need to change the language to C++17, which might give more problems…

So, I changed to C++17, I replaced “ghc” with “std” and it said that "filesystem' is not a member of 'std'

I googled it and found here that I should include #include <experimental/filesystem>

I did so, and then… the “chrono” errors are back :frowning:

The only other thing I can think of is that I’m using version 16.9 Perhaps try updating VS 2019 to the very latest version that is on offer? I think it’s 16.11…