olli
yes globals, why would you forward declare local variables?
olli
screenshot for mobile users, flags: msvc: /Wall gcc/clang: -std=c11 -pedantic -Wall -O3
Vlad
it's because it's defaulted to extern in the global scope in C
Alex
a is defined two times
Aj
When we write cout<<string[-1] . Is it any kinda error ?
Aj
It's just variable of type string
Vlad
All globals are zero initialized if isn't set otherwise
Vlad
statics, etc
Talula
It shouldn't... your compiler is crazy.
Talula
if you declare int a; (globally) then do int a = 10; in main or function, you're simply redeclaring the variable.
Wisenky
dude gimme a git repo
https://github.com/pipd0un/vcar_cpp_logic
Vlad
C standard shenanigans
Wisenky
https://github.com/pipd0un/vcar_cpp_logic
/include/c++/bits/basic_string.h:182: multiple definition of `Map::Laby' src/main.o:C:\Users\...\workspace\vcar_cpp_logic/inc/map.h:57: first defined here collect2.exe: error: ld returned 1 exit status I cant get rid of this lub :(
Wisenky
cant implement same arg twicce ?
Wisenky
variable I mean
Wisenky
what should I do now
Engineer
We are talking about zero again 🤓https://www.bruceeckel.com/2020/07/30/we-havent-invented-zero-yet/
Wisenky
in map.h doesnt include car.h now but still multiple definiton error comes
Wisenky
thanks a lot sir : https://github.com/pipd0un/vcar_cpp_logic
Sachin
/get
su
https://github.com/pipd0un/vcar_cpp_logic
refactor source code in that way, that .h files not depends on .h files
Pavel
in map.h doesnt include car.h now but still multiple definiton error comes
That's ODR violation, you either put your variable definitions to *.cpp or declare them inline
Wisenky
That's ODR violation, you either put your variable definitions to *.cpp or declare them inline
oh thanks in map.h I did ... class Map{...}; inline Map Map::Laby; and solved
Pavel
oh thanks in map.h I did ... class Map{...}; inline Map Map::Laby; and solved
If you want to know more, google about how compilation process is working in general terms, keywords are: definition vs declaration, translation unit, ODR
Wisenky
Wisenky
If you want to know more, google about how compilation process is working in general terms, keywords are: definition vs declaration, translation unit, ODR
so whenever I implement func and variables in header , I can include that header in a .cpp file just 1 time . More will bring me Odr
Pavel
oh If I implement in a .cpp file the map.h declarations , will I face this multiple definition error
If you do it properly and consistently throughout you programs, you should not encounter such problems. In most of the code that you can find today it's done this way with all the definitions in *.cpp (mostly because inline variables is a relatively new C++ feature).
Pavel
so whenever I implement func and variables in header , I can include that header in a .cpp file just 1 time . More will bring me Odr
If it is not inline, yes. But some of the functions and variables are inline by default. E.g. constexpr variables and functions, templated functions (not sure if it's 100% correct term), member functions
Pavel
so whenever I implement func and variables in header , I can include that header in a .cpp file just 1 time . More will bring me Odr
You should write your headers in a way so that they can be safely included to multiple cpp files
Wisenky
You should write your headers in a way so that they can be safely included to multiple cpp files
uhm I have question again. I wrote my map class as a singleton in map.h .And couldnt find a good example to implement them in a .cpp file for a beginner me. Would you lead me
Pavel
uhm I have question again. I wrote my map class as a singleton in map.h .And couldnt find a good example to implement them in a .cpp file for a beginner me. Would you lead me
I'm not near my computer so can't find an example, I suggest you to google "Meyers singleton", articles about this one usually contain good descriptive examples (also it's by default choice when you need a singleton)
Anonymous
???
warrior404
Hello my friends. This question is me too.? Thanks
Dima
Read the rules
V01D
I need to use SOIL2 for my openGL stuff. My os is manjaro linux, and I have issues installing and linking it. Meaning the header file is not in /usr/include (which is fine I just copied it into my local directory) and I cannot link it. I don't know what to input for the linker (-l???
V01D
Idk what else to do
V01D
The documentation is really lacking. It is based off of SOIL if that helps 🤷‍♂️
V01D
You mean use the -I flag in my makefike
V01D
I just want it to work right now. That's all I care about
V01D
No. I cloned it from the repo, and followed the steps. premake gmake CD make/linux make
Ammar
I need to use SOIL2 for my openGL stuff. My os is manjaro linux, and I have issues installing and linking it. Meaning the header file is not in /usr/include (which is fine I just copied it into my local directory) and I cannot link it. I don't know what to input for the linker (-l???
Usually it uses -L flag to specify the shared library directory to be linked. For example, if you have a shared library file named "libtest.so" located at directory /aa/bb/cc, and you want to link it, then your flags can be. cc ...something here... -L/aa/bb/cc -ltest Notice that your write -ltest, not -llibtest.
V01D
github.com/SpartanJ/soil2 is the repo name
V01D
Undefine reference to SOIL_load_OGL_texture
Ammar
What to do in this case: 1. What is the undefined reference? 2. Find the library. 3. Make sure the reference symbol exists on that library (objdump may help + less).
V01D
I just copy and pasted an example snippet from the repo
V01D
I am pretty sure. But it can't be missing, I followed the instructions and got no errors..
V01D
What does that mean?
Ammar
Undefine reference to SOIL_load_OGL_texture
Meaning that you haven't compiled SOIL2.c, I found the definition on there.
Ammar
V01D
So I have to compile the source files
Ammar
Yes, compile them to objects and link them together.
V01D
And then I can just link soil?
V01D
Did that Just with premake5
V01D
Didn't work
V01D
Still no idea what to link. I mean the make file ran and all but idk what linker command
V01D
I tried to compile the test_SOIL.cpp file from the repo
V01D
Yes
V01D
I did that
V01D
Same error. It seems that the .a and .so files are unusable
V01D
Lemme try that
V01D
Yeah I know that
V01D
Still won't work. -static breaks all other linkages
V01D
Okay, lemme try
V01D
No still undefined reference
V01D
Screw it, I will use a different library. Any recommendations for an OpenGL image loading library that isn't SOIL2?
Anonymous
Hi
V01D
@sajjad_rmg No DM without asking for permission
Anonymous
Hi
V01D
Dunno. I just used SOIL instead of SOIL2.
V01D
Thanks for the help though
Raj Kumar
Raj Kumar: Any body knows about intent redirection vurnability In android During uploading in play console
Anonymous
hello. Can anyone help me? I'm really confused. I've been asked to write a C++ program for this algorithm, but I can't because I'm new 😔
V01D
I will try that another day. I need to get some work done now
Vlad
Dunno. I just used SOIL instead of SOIL2.
Why doesn't this lib have proper cmake