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

error: ‘isnan’ was not declared in this scope #1

Open
Zauberfisch opened this issue Jan 7, 2019 · 5 comments
Open

error: ‘isnan’ was not declared in this scope #1

Zauberfisch opened this issue Jan 7, 2019 · 5 comments

Comments

@Zauberfisch
Copy link

Building fails for me with the error message:

g++ -Ofast -std=c++11 -Wall -Wno-unused-function -I/usr/local/include/ -I/usr/include `pkg-config --cflags jack` `pkg-config --cflags libpulse` -c jack_volume.cpp -o jack_volume.o
jack_volume.cpp: In member function ‘void jack_volume::channel_lin(int32_t, float)’:
jack_volume.cpp:163:14: error: ‘isnan’ was not declared in this scope
   JV_ASSERT(!isnan(new_gain_lin), "new_gain_lin is not a number");
              ^~~~~
jack_volume.cpp:24:37: note: in definition of macro ‘JV_ASSERT’
 #define JV_ASSERT(cond, msg) if (! (cond)) throw std::runtime_error(msg)
                                     ^~~~
make: *** [Makefile:35: jack_volume.o] Error 1

gcc --version: gcc (GCC) 8.2.1 20181127
uname -a: Linux fishbowl-g1 4.19.13-1-MANJARO #1 SMP PREEMPT Sat Dec 29 15:43:56 UTC 2018 x86_64 GNU/Linux

Given that this is just input validation, I removed that line and was then able to compile it.

@hboetes
Copy link

hboetes commented Jun 5, 2020

According to: https://en.cppreference.com/w/c/numeric/math/isnan you have to include these headers:

#include <stdio.h>
#include <math.h>
#include <float.h>

@hboetes
Copy link

hboetes commented Jun 5, 2020

diff --git a/Makefile b/Makefile
index 71f5dac..07cdd48 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ CXXFLAGS = -Ofast -std=c++11 -Wall -Wno-unused-function
 LIBS = `pkg-config --libs jack` `pkg-config --libs libpulse` -pthread
 INCLUDE = -I/usr/local/include/ -I/usr/include `pkg-config --cflags jack` `pkg-config --cflags libpulse`
 
-GCC = g++
+CXX = c++
 
 JV_SOURCES = jack_volume.cpp
 JV_OBJS = $(JV_SOURCES:.cpp=.o) /usr/local/lib/libOSC++.a
@@ -12,24 +12,20 @@ PAV_OBJS = $(PAV_SOURCES:.cpp=.o) /usr/local/lib/libOSC++.a
 PAV_TARGET = pa-volume
 
 all: $(JV_OBJS) $(PAV_OBJS)
-	$(GCC) -o $(JV_TARGET) $(JV_OBJS) $(LIBS)
-	$(GCC) -o $(PAV_TARGET) $(PAV_OBJS) $(LIBS)
+	$(CXX) -o $(JV_TARGET) $(JV_OBJS) $(LIBS)
+	$(CXX) -o $(PAV_TARGET) $(PAV_OBJS) $(LIBS)
 
 install: $(JV_TARGET) $(PAV_TARGET)
-	cp -f $(JV_TARGET) /usr/local/bin/
-	cp -f $(PAV_TARGET) /usr/local/bin/
-	cp -f jvctl.py /usr/local/bin/jvctl
-	cp -f udp_dispatcher.py /usr/local/bin/udp_dispatcher
-	cp -f generic_connector.py /usr/local/bin/generic_connector
-	chmod a+rx /usr/local/bin/$(JV_TARGET)
-	chmod a+rx /usr/local/bin/$(PAV_TARGET)
-	chmod a+rx /usr/local/bin/jvctl
-	chmod a+rx /usr/local/bin/udp_dispatcher
-	chmod a+rx /usr/local/bin/generic_connector
+	install -d $(DESTDIR)/usr/local/bin
+	install $(JV_TARGET) $(DESTDIR)/usr/local/bin/
+	install $(PAV_TARGET) $(DESTDIR)/usr/local/bin/
+	install jvctl.py $(DESTDIR)/usr/local/bin/jvctl
+	install udp_dispatcher.py $(DESTDIR)/usr/local/bin/udp_dispatcher
+	install generic_connector.py $(DESTDIR)/usr/local/bin/generic_connector
 
 clean:
 	rm -f $(JV_SOURCES:.cpp=.o) $(JV_TARGET)
 	rm -f $(PAV_SOURCES:.cpp=.o) $(PAV_TARGET)
 
 %.o:%.cpp
-	$(GCC) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
+	$(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
diff --git a/jack_volume.cpp b/jack_volume.cpp
index c4f2307..d6d4086 100644
--- a/jack_volume.cpp
+++ b/jack_volume.cpp
@@ -8,6 +8,11 @@
 #include <iostream>
 #include <vector>
 #include <thread>
+
+#include <stdio.h>
+#include <math.h>
+#include <float.h>
+
 extern "C" {
 	#include <jack/jack.h>
 }

voidseg added a commit that referenced this issue Jul 6, 2020
@voidseg
Copy link
Owner

voidseg commented Jul 6, 2020

Thanks for your feedback! Please confirm the fixed version in branch fix-isnan.

Best regards
voidseg

@Zauberfisch
Copy link
Author

sorry, I'm not gonna be able to test it at this time. Perhaps @hboetes could test it?

@hboetes
Copy link

hboetes commented Jul 16, 2020

I already tested it, it's simply the patch I suggested.

voidseg added a commit that referenced this issue Sep 25, 2020
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

3 participants