pschatzmann / arduino-audio-tools

Arduino Audio Tools (a powerful Audio library not only for Arduino)
GNU General Public License v3.0
1.27k stars 199 forks source link

variable-sized object may not be initialized #1521

Closed jaapnoordzij closed 1 month ago

jaapnoordzij commented 1 month ago

Problem Description

I am trying to "cmake" the generator desktop example. It fails with an error:

/Users/jaapnoordzij/Documents/Arduino/libraries/arduino-audio-tools/src/AudioBasic/StrExt.h:129:17: error: variable-sized object may not be initialized
    char result[new_size + 1] = {0};

Is this an error in the code or can I specify some flag to prevent the error ?

Device Description

Desktop build on MacOS Sonoma 14.4.1 I have done a 'git pull' just before compiling

Sketch

examples_desktop/generator (unmodified)

Other Steps to Reproduce

No response

What is your development environment

No response

I have checked existing issues, discussions and online documentation

pschatzmann commented 1 month ago

Strange: I can't reproduce your problem. What compiler version are you using ? If you run make -i do you get other errors ?

I was testing with

g++ -v 
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.4.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) 
jaapnoordzij commented 1 month ago

Apple standard distribution

Apple clang version 15.0.0 (clang-1500.3.9.4) Target: x86_64-apple-darwin23.4.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

On Mon, Apr 22, 2024 at 12:01 PM Phil Schatzmann @.***> wrote:

Strange: I can't reproduce your problem. What compiler version are you using ?

— Reply to this email directly, view it on GitHub https://github.com/pschatzmann/arduino-audio-tools/issues/1521#issuecomment-2068988254, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFUT3AZVYUFJXCXACZPHTDY6TNZNAVCNFSM6AAAAABGSOAX4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRYHE4DQMRVGQ . You are receiving this because you authored the thread.Message ID: @.***>

--

Please do not reply to this email since I hardly ever read it.

Kind regards, Jaap Noordzij

pschatzmann commented 1 month ago

I committed a correction: it's compiling now with clang as well...

jaapnoordzij commented 1 month ago

Perfect, Thank you !

jaapnoordzij commented 1 month ago

The generation example compiles and runs fine now. But what I actually wanted to do is play around with STK on my laptop. So next I want to cmake ~/Documents/Arduino/libraries/arduino-audio-tools/examples/examples-dsp/examples-stk/streams-stk-desktop without any modifications just from the example.

In the Mac terminal I navigate to this directory, mkdir build, cd build and run cmake -DCMAKE_BUILD_TYPE=Debug ..

Apparently the cmake system sets the variable for CMAKE_SOURCE_DIR wrong because I get an error:

CMake Error at CMakeLists.txt:20 (add_subdirectory):
  The source directory

    /Users/jaapnoordzij/Documents/Arduino/libraries/arduino-audio-tools/examples

  does not contain a CMakeLists.txt file.

I am an absolute beginner with cmake and the documentation only shows me the the source dir should be set to the directory .. that contains the CMakeLists.txt file (it is there !). Why does cmake select a dir that is some levels up ?

What am I doing wrong ?

pschatzmann commented 1 month ago

It seems that I have moved the directories a bit, so the cmake needed to be adjusted as well: the releative path to the audio-tools root directory was wrong. I committed a correction which is looking one level higher now

jaapnoordzij commented 1 month ago

Almost there, compilation works OK now, thank you, but:

`/Users/jaapnoordzij/Documents/Arduino/libraries/arduino-audio-tools/src/AudioLibs/I2SCodecStream.h:2:10: fatal error: 'AudioBoard.h' file not found

include "AudioBoard.h" // install audio-driver library`

pschatzmann commented 1 month ago

Just comment it out: this is only needed if you compile it for an AudioKit but you need #include "AudioLibs/PortAudioStream.h"

jaapnoordzij commented 1 month ago

Commenting out the include gives more than 20 errors Commenting out all occurrences of 'Audioboard' (about 9 lines) give more than 20 other errors Is there another trick to exclude it ?

pschatzmann commented 1 month ago

From above: but you need #include "AudioLibs/PortAudioStream.h"

With the last commit it is working for me...

jaapnoordzij commented 1 month ago

Yes of course, that was a dumb reaction of me, I realized that only later on. Thank you, works perfectly now.