Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for a compilation error #4

Open
FlorentRevest opened this issue May 1, 2014 · 2 comments
Open

Fix for a compilation error #4

FlorentRevest opened this issue May 1, 2014 · 2 comments

Comments

@FlorentRevest
Copy link

I tried to compile lv2-mdaMetaPiano but met a gcc error because of the initialisation of "samples" in the header mdaPiano.h instead of the constructor in mdaPiano.cpp. So I had to move the following initialisation line out of the header :

Sample samples = (Sample) malloc (NSAMPLES * sizeof(Sample));

It might help someone else.

@rekado
Copy link
Owner

rekado commented May 2, 2014

What exactly is the error message GCC printed? What GCC version are you using? How did you invoke the make command?

I cannot reproduce this with GCC 4.8.2 on Fedora 20 with PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig/ make.

@FlorentRevest
Copy link
Author

I'm using GCC 4.6.3 on Ubuntu 12.04. I just used the make command in the src folder and I get this error:

g++ -fPIC -DPIC -O -g -Wall -pedantic -DPIANO -shared *.cpp `pkg-config --cflags --libs lvtk-plugin-1` -o mdaPiano.so
In file included from mdaPiano.cpp:16:0:
mdaPiano.h:26:31: error: ‘void* malloc(size_t)’ cannot appear in a constant-expression
mdaPiano.h:26:64: error: a function call cannot appear in a constant-expression
mdaPiano.h:26:64: error: a cast to a type other than an integral or enumeration type cannot appear in a constant-expression
mdaPiano.h:26:64: error: ISO C++ forbids initialization of member ‘samples’ [-fpermissive]
mdaPiano.h:26:64: error: making ‘samples’ static [-fpermissive]
mdaPiano.h:26:64: error: invalid in-class initialization of static data member of non-integral type ‘Sample*’
mdaPiano.h: In destructor ‘mdaPiano::~mdaPiano()’:
mdaPiano.h:18:12: error: ‘samples’ was not declared in this scope
mdaPiano.h:20:10: error: ‘samples’ was not declared in this scope
mdaPiano.cpp: In constructor ‘mdaPiano::mdaPiano(double)’:
mdaPiano.cpp:52:18: error: ‘samples’ was not declared in this scope
mdaPiano.cpp:59:41: error: ‘samples’ was not declared in this scope
mdaPiano.cpp: At global scope:
mdaPiano.cpp:315:12: warning: ‘_’ defined but not used [-Wunused-variable]
make: *** [mdaPiano.so] Error 1

By just keeping

Sample *samples;

In the header and moving

samples = (Sample*) malloc (NSAMPLES * sizeof(Sample));

to the line 25 of mdaPiano.cpp I get rid of the error.

Anyway thanks for the good work I have a lot of fun playing with this synth!

P.S: sorry I'm not used to making patch and the error is easy to remove

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants