soul-lang / SOUL

The SOUL programming language and API
Other
1.71k stars 96 forks source link

link error in code generated by SOUL 1.0.82 #59

Closed wtholliday closed 3 years ago

wtholliday commented 3 years ago

I'm getting a link error when compiling with clang/osx for the DiodeClipper example.

Undefined symbols for architecture x86_64:
  "Diode::parameters", referenced from:
      Diode::createParameterList() in CAudioKit.o

When I move the definition of Diode::parameters to a cpp file, it links. Diode::parameters is a constexpr so I would have expected it to only need a definition in the class, unlike a normal static variable.

Also, the code generated by 1.0.82 says 0.9.0 at the top. I've double-checked that I'm running 1.0.82:

% ~/bin/soul | head

   _____ _____ _____ __ 
  |   __|     |  |  |  |     SOUL toolkit
  |__   |  |  |  |  |  |__   (C)2020 ROLI Ltd.
  |_____|_____|_____|_____|

  SOUL version 1.0.82
  Build date: Feb  5 2021 18:44:37
  LLVM version: 9.0.1

% ~/bin/soul generate --cpp DiodeClipper.soul | head
Building: /Users/holliday/AudioKit/Sources/CAudioKit/Nodes/Effects/Distortion/DiodeClipper.soul
Building: /Users/holliday/AudioKit/Sources/CAudioKit/Nodes/Effects/Distortion/DiodeClipper.soul
//      _____ _____ _____ __
//     |   __|     |  |  |  |        Auto-generated C++
//     |__   |  |  |  |  |  |__      SOUL Version 0.9.0
//     |_____|_____|_____|_____|     https://soul.dev
//

#include <array>
#include <functional>
#include <cmath>
#include <cstddef>
cesaref commented 3 years ago

Thanks for the report, we're investigating.

julianstorer commented 3 years ago

This turns out to be because our code uses inline constexpr statics, which is a C++17 feature. if you recompile with your compiler set to C++17 or later then it should work fine.

I'm going to add a check to the generated code so that it fails for < C++17 to avoid any confusion, and we'll also sort out the version number, thanks for flagging that!