Right after moving a source-file from my project to a subdirectory, gcc spit out a weird error (it did compile perfectly fine before)
make[3]: Entering directory '/home/rd/Desktop/fh/bf4/bbx/o4x/server/server_app/src'
CXX main.o
In file included from /usr/include/c++/9/bits/stl_algobase.h:69,
from /usr/include/c++/9/memory:62,
from /usr/include/c++/9/memory_resource:37,
from main.h:5,
from main.cpp:1:
./debug/debug.h:14:28: error: variable or field ‘debug_queue_addN’ declared void
14 | void debug_queue_addN(std::string msg);
| ^~~~~~
compilation terminated due to -Wfatal-errors.
I did managed to 'resolve' that problem by including < string > in said header file, however a new, even weirder error appeared.
make[3]: Entering directory '/home/rd/Desktop/fh/bf4/bbx/o4x/server/server_app/src'
CXX main.o
In file included from /usr/include/c++/9/bits/stl_algobase.h:69,
from /usr/include/c++/9/memory:62,
from /usr/include/c++/9/memory_resource:37,
from main.h:5,
from main.cpp:1:
./debug/debug.h:14:28: error: variable or field ‘debug_queue_addN’ declared void
14 | void debug_queue_addN(std::string msg);
| ^~~~~~
compilation terminated due to -Wfatal-errors.
At this point I even tried including < algorithm > before any other inclusion anywhere else, but it didn't help at all. Instead it threw out this even weirder error...
make[3]: Entering directory '/home/rd/Desktop/fh/bf4/bbx/o4x/server/server_app/src'
CXX main.o
In file included from /usr/include/c++/9/bits/basic_string.h:48,
from /usr/include/c++/9/string:55,
from ./debug/debug.h:4,
from /usr/include/c++/9/bits/stl_algobase.h:69,
from /usr/include/c++/9/bits/char_traits.h:39,
from /usr/include/c++/9/ios:40,
from /usr/include/c++/9/ostream:38,
from /usr/include/c++/9/iostream:39,
from main.cpp:2:
/usr/include/c++/9/string_view: In member function ‘std::basic_string_view<_CharT, _Traits>::size_type std::basic_string_view<_CharT, _Traits>::copy(_CharT*, std::basic_string_view<_CharT, _Traits>::size_type, std::basic_string_view<_CharT, _Traits>::size_type) const’:
/usr/include/c++/9/string_view:260:32: error: ‘min’ is not a member of ‘std’; did you mean ‘minus’?
260 | const size_type __rlen = std::min(__n, _M_len - __pos);
| ^~~
| minus
compilation terminated due to -Wfatal-errors.
Now, does anybody have an idea why this happens/ what I can do to fix this?
Also, here's the in the error output mentioned code.
main.cpp
#include "main.h"
#include "server.h"
#include "config.h"
#include "debug/debug.h"
#include "pidfile.h"
#include "messages.h"
#include <cstring>
#include <iostream>
#include <thread>
#include <algorithm>
[CUT HERE]
main.h
#ifndef __MAIN_H___
#define __MAIN_H___
#define __cpp_transactional_memory 0
#include <memory_resource>
extern std::pmr::synchronized_pool_resource* _upstream_resource;
extern std::pmr::pool_options _general_pool_options;
#endif
debug/debug.h
#ifndef __DEBUG_H__
#define __DEBUG_H__ 1
#include <string> // I added this as a 'solution' to the first mentioned problem
#include "config.h"
#ifdef DEBUGBUILD
#define dbg_out(a) debug_queue_addN(a)
#define dbg_sout(func, msg) this->debug_queue_add(func, msg)
#define dbg_csout(inh, func, msg) debug_queue_addI(inh, func, msg)
#define fatal_err_out(a) std::cout << a
void debug_print();
void debug_queue_addN(std::string msg);
void debug_queue_addI(std::string inh, std::string func, std::string msg);
#else
#define dbg_out(a)
#define dbg_sout(func, msg)
#define dbg_csout(inh, func, msg)
#define fatal_err_out(a) std::cerr << a
#endif
#endif
and finally Makefile.am
SUBDIRS =
EXTRA_DIST =
bin_PROGRAMS =
#check_PROGRAMS =
#TESTS =
GENERAL_GCC_FLAGS = -std=gnu++17 \
-Og -falign-functions \
-falign-jumps -falign-labels \
-falign-loops -fwrapv \
-fbranch-target-load-optimize \
-fasynchronous-unwind-tables \
-fcode-hoisting -fdce -fdse \
-fgcse -fhoist-adjacent-loads \
-fipa-icf -fipa-cp -fipa-pta -fipa-vrp \
-fplt -fpeephole -freorder-functions \
-fstack-protector-all -m80387 -mhard-float \
-malign-double -mcld -mcx16 -msahf -mmovbe -mcrc32 \
-mrecip -mprefer-avx128 -mmmx -msse4.2 -mavx512vbmi \
-msha -maes -mrdrnd -mf16c -pthread -mpc80 -m64 -g3 -fconcepts \
[CUT OUT a whole lot of -Wxxxxx]
# --param asan-stack=1 --param asan-instrument-allocas=1 \
# --param asan-globals=1 --param asan-instrument-writes=1 \
# --param asan-instrument-reads=1 --param asan-memintrin=1 \
# --param asan-use-after-return=1 --param asan-instrumentation-with-call-threshold=1 \
# -fsanitize=address
GENERAL_FLAGS = $(GENERAL_GCC_FLAGS)
AM_CFLAGS = $(WARNCFLAGS) $(GENERAL_FLAGS)
AM_CXXFLAGS = $(WARNCXXFLAGS) $(CXX1XCXXFLAGS) $(GENERAL_FLAGS)
AM_CPPFLAGS = $(GENERAL_FLAGS)
LDADD = @LIBXML2_LIBS@ \
@LIBEV_LIBS@ \
@OPENSSL_LIBS@ \
@SYSTEMD_LIBS@ \
@JANSSON_LIBS@ \
@ZLIB_LIBS@ \
@APPLDFLAGS@
bin_PROGRAMS += server_app
server_class_packetEx_SOURCES = packets/dcs_do.cpp packets/hbp_do.cpp packets/ack_do.cpp
server_class_SOURCES = server.cpp perform_commands.cpp handle_commands.cpp server_message_byte_strs.cpp \
networking.cpp messages.cpp packet_check.cpp send_packages.cpp errors.cpp $(server_class_packetEx_SOURCES)
auth_class_SOURCES = auth/authentication.cpp
debug_SOURCES = debug/debug.cpp
server_app_SOURCES = main.cpp export.cpp pidfile.cpp $(server_class_SOURCES) $(auth_class_SOURCES)
if DEBUGBUILD
server_app_SOURCES += $(debug_SOURCES)
endif
From the errors, it seems that your debug/debug.h
is being picked up by /usr/include/c++/9/bits/stl_algobase.h
. This conflicts with the actual /usr/include/c++/9/debug/debug.h
.
On my system at least, these includes are done using the #include <...>
form, ie by searching the system include path. It looks like you added compilation flags that put your code also on that path. Something as innocent as -I.
, perhaps?
To solve this problem you should either get rid of the extra -I
flag or rename your debug/debug.h
file.