klimi
Hi I have query in c++ I have a double number suppose 1.45678384 i want that double takes only four digits after decimal number what is the methods
default floating point types do not have variable resolution. If you need fixed decimal point you will need to program it yourself
yz
thank you guys
vndtta
.. = {false};
bitset<n> x{}; also ok
ᴅᴀᴠɪᴅ 𝚁. | ᴘʀᴏ 𓅃
Hello, I am a new C/CPP programmer and I have some questions that I need answered now. After learning C/Cpp, will I be able to create programs like wine and proton used in Steam Deck? I also have a question: How is wine built? What is its idea? I also have a question. People say that if you learn C, CPP, and the basics of computer science, you will be able to program anything, whatever, after learning and mastering them, and you will understand every 0 and 1 in front of you. Is this correct? If so, then I hope someone can help me as I enter the field of computer science.
John
There are reasons why we need advanced programming language, and one of them is to avoid looking directly into 01010101😜
harmony5 🇺🇳 ⌤
Rose
Can you help me with other things I need to learn? Or Roadmap
Please check out this channel - @Resources for information on learning sources for C and C++ (books and videos) and Frequently Asked Questions.
yz
what is the default value of int in struct data ? is it 0 ? i would usually do something like "int a=0", but in struct i cant do that, so is the default value of int in struct is 0 ? in c btw
Doraemon
Leovan
what is the default value of int in struct data ? is it 0 ? i would usually do something like "int a=0", but in struct i cant do that, so is the default value of int in struct is 0 ? in c btw
Firstly, you can (since C++11): struct A { int a = 5; }; Secondly, it depends on where you will create an object with this struct type. If like global variable then its value is guaranteed to be 0 (since bss segment will be zeroed at program startup). If it is local variable then it will store some garbage (because it will be very expensive to set 0 to local (on stack) variables each time)
Michael
I was about to answer, but I found that you answered faster and better than me.😂
Michael
in c, you can also use struct A a1 = {0, 0} to explicitly initialize the local struct variables
Michael
And I strongly recommend this method, unless you have to make it globally
yz
woww thank you this is what im looking for
Rose
Not enough arguments!
Thomas
How do I cross compile for windows on Linux?
Thomas
How do I cross compile for windows on Linux?
I want a built in Linux command to make it instead of searching and needing to manually download some other tool
Thomas
Cmake?
Does that make windows compatible binaries?
Viacheslav
Does that make windows compatible binaries?
Yes, if you do some code for windows. if(UNIX) # your CMAKE code elseif(WIN32) # your CMAKE code endif()
Viacheslav
Does that make windows compatible binaries?
Also it is common for unix to install packages, so you include it like find_package(package_name), but for windows you need to include path include_directories("path")
Steve
make it for linux and use it on windows with wsl
dontu
make it for linux and use it on windows with wsl
Or make it for windows and use wine :D
Simple Sorcerer
Cmake?
No. This is just a constructor for convenience
klimi
please read the group name, then group rules and then delete your offtopic messages, thank you
Rose
User biochem has 1/2 warnings; be careful! Reason: offtop
Simple Sorcerer
Simple Sorcerer
gcc
on linux there's a package called something like mingw-gcc.
Simple Sorcerer
do a search in your package manager
Thomas
on linux there's a package called something like mingw-gcc.
my original question has alr been answered but thanks for the help anyway
Juan
hi everyone,im using msys2 to run g++ on windows10 but when i use g++ to compile c++ file, i got this C:\Users\Jose\Documents\GitHub\casualcode\cpp\hello>g++ hello.cpp -Wl,--verbose Supported emulations: i386pep i386pe collect2.exe: error: ld returned 116 exit status version info mingw-w64-ucrt-x86_64-gcc 13.2.0-5 mingw-w64-ucrt-x86_64-binutils 2.42-1 how could i gather more debug information?
Ziky
I looks like your linker support i386 only
Brooklyn
I looks like your linker support i386 only
Doesn’t that mean 32 bit processor
Simple Sorcerer
The translator seems to be broken 😅
Simple Sorcerer
I also collect x32 attachments. they will run everywhere
Brooklyn
yes
Don’t 64 bit processors have the capability to run 32 bit programs
Simple Sorcerer
Don’t 64 bit processors have the capability to run 32 bit programs
I did not explain it correctly. I have a translator who even put money in the offer
Brooklyn
/report
Rose
/report
Reported to admins.​​​​​​​​​​​
Rose
Reported to admins.​​​​​​​​​​​
Danya🔥
Brooklyn
Read the rules no hello
Brooklyn
It is mentioned in the 2nd paragraph
Viacheslav
Read the rules no hello
Wrong rule i guess. It is hard to imagine any networking event, where people do not greet each other
Brooklyn
Wrong rule i guess. It is hard to imagine any networking event, where people do not greet each other
If you want to greet others and talk about anything just join the ot group and say whatever you want as long as you are following the ot groups rules which are not taken that seriously as they are in the official group
Juan
hi everyone,im using msys2 to run g++ on windows10 but when i use g++ to compile c++ file, i got this C:\Users\Jose\Documents\GitHub\casualcode\cpp\hello>g++ hello.cpp -Wl,--verbose Supported emulations: i386pep i386pe collect2.exe: error: ld returned 116 exit status version info mingw-w64-ucrt-x86_64-gcc 13.2.0-5 mingw-w64-ucrt-x86_64-binutils 2.42-1 how could i gather more debug information?
casualcode\cpp\hello on  main ❯ c:\msys64\ucrt64\bin\g++.exe -g C:\Users\Jose\Documents\GitHub\casualcode\cpp\hello\hello.cpp -o C:\Users\Jose\Documents\GitHub\casualcode\cpp\hello\hello.exe '-Wl,--verbose' -static-libstdc++ Supported emulations: i386pep i386pe casualcode\cpp\hello on  main ❯ ls Directory: C:\Users\Jose\Documents\GitHub\casualcode\cpp\hello Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 4/8/2024 7:51 PM 298 hello.cpp -a--- 4/11/2024 10:18 PM 2914740 hello.exe casualcode\cpp\hello on  main ❯ .\hello.exe Hello C++ World from VS Code and the C++ extension! casualcode\cpp\hello on  main ❯ c:\msys64\ucrt64\bin\g++.exe -g C:\Users\Jose\Documents\GitHub\casualcode\cpp\hello\hello.cpp -o C:\Users\Jose\Documents\GitHub\casualcode\cpp\hello\hello.exe '-Wl,--verbose' Supported emulations: i386pep i386pe collect2.exe: error: ld returned 116 exit status casualcode\cpp\hello on  main took 3s ❯
Juan
some more info: if static-libstdc++ is passed, it works im tryna learn to use something like strace, wish me luck
Leovan
Because it allows to optimize the width of the underlying type based on the enumerators and their values
because of this we have bug on msvc 🙃: https://walac.github.io/curious-bug-enum-bitfield/
Danya🔥
because of this we have bug on msvc 🙃: https://walac.github.io/curious-bug-enum-bitfield/
You have the bug in msvc not because of the standard but because of Microsoft employees
Danya🔥
MSVC is a bug in itself
Danya🔥
I'm hoping someday Microsoft gonna bury this thing and use clang, as Intel did
D
Are there any advantages of using msvc over clang, though? Except ergonomics
Danya🔥
MSVC has better support of newer standards
Leovan
I'm hoping someday Microsoft gonna bury this thing and use clang, as Intel did
what about gcc/g++? I know that clang has better errors in some cases
Artur
MSVC has better support of newer standards
Where is the support for C++ 23 compiler features ?
Artur
Even Apple clang is ahead of MSVC in terms of compiler features … 😅
Dima
clang one love
Pavel
Even Apple clang is ahead of MSVC in terms of compiler features … 😅
Well, at least MSVC is more consistent now, clang/gcc add support to newer features, but for very long time don't support some stuff from older standards
Ludovic 'Archivist'
Even Apple clang is ahead of MSVC in terms of compiler features … 😅
Not really true. MSVC may be shitty at optimization, but it is very up to date. For example, GCC still does not have a compliant version of the from_chars and to_chars for floating points and uses sprintf under the hood
Ludovic 'Archivist'
The implementation of concepts is also a bit weird at times, with some unhandled cases I can't remember
Ludovic 'Archivist'
MSVC are not catching up on the compiler side of c++23, but have almost all library items including a bunch missing from both clang and gcc
Artur
Not really true. MSVC may be shitty at optimization, but it is very up to date. For example, GCC still does not have a compliant version of the from_chars and to_chars for floating points and uses sprintf under the hood
I am not talking about library implementation, but compiler implementation. What features MSVC compiler supports from C++23? Partial implementation of deducing this, consistent character encoding support for utf8 as portable source file encoding and couple more features and that’s about all 😅😅😅😅😅
Ludovic 'Archivist'
No, it is true
Look at the library items now