Vlad
In fixed Size array how we get to know it Is stack or heap Allocation
char arr[10]; // stack char* arr = new char[10]; // heap
Vlad
If you don't say new or malloc or use containers it's stack
Vlad
Unless it's a static variable. Then it's a freaking static variable
FriedRice
The chance of you need to use the keyword new is very low in C++, given there are so many STL container types. You can assume all are stored on the stack except for STL objects.
Rose
Please check out this channel - @Resources for information on learning sources for C and C++ (books and videos) and Frequently Asked Questions.
Hamid
char arr[10]; // stack char* arr = new char[10]; // heap
char *arr isn't correct ?
Vlad
char *arr isn't correct ?
It is equivalent to char* arr;
Never Spam Bot
Krunal Dhoriya sent multiple messages that looks like a spam. To stop the bot from deleting your messages, write something non-suspicious. Or find out why here. Spam deleted in this group: 2745
S
anyone help me for vs code setting
Suka
c language
windows or linux?
Suka
windows
until you learn environment variable and how to exclude directory from antivirus, the easy way to setup vscode for c/cpp is to install msvc community edition and then install vscode + ms c/cpp extension. but you need to launch vscode inside msvc cli shell. cmiiw.
Rose
User Ventura has 1/2 warnings; be careful! Reason: Automated blocklist action, due to a match on: t.me/joinchat/*
Rose
User Harsh has 1/2 warnings; be careful! Reason: spam
itsmanjeet
Hey I need help in setting up openCL on android App, I don't know how to use library available at /vendor/lib64/libOpenCL.so I configure gradle to link the code with local copy of libOpenCL.so but its keep complaining for dependent libraries of libOpenCL.so during runtime,
Rose
Reported Augmented Anarchy [86947553] to admins.​​​​​​​​​​
$cram!
/report
Rose
/report
Reported to admins.​​​​​​​​​​
Natxo
Good evening winter, I have started a C++ programming project with the LVGL library and an ILI9341 display connected by SPI to a Raspberry Pi Zero W, I can't get a first compilation successful... it gives me a lot of errors with the reference to the lvgl and lv_drivers libraries and I can't get it to compile without errors to continue with the development, I have gone around in circles, if someone can help me I can attach the project files + compilation script. I am very new to the group and I don't know if these types of ZIP files can be added. I thank you in advance for any help !!
Coral
When shared/unique ptrs are practically using new without specify explicitly the word "new"
kazeka
anyone help me for vs code setting
u just need to find some video on youtube
kazeka
it is a lot of diffent videos
kazeka
u can use MSYS2
Rose
User Siddhanth has 1/2 warnings; be careful! Reason: yt short
Natxo
ESP-IDF or Arduino IDE?
I'm working with Raspberry Pi OS without desktop, connected with ssh and editing remotely with ZED editor.
Natxo
What are the specific compilation error messages?
These are my mistakes and I attach project sources. https://www.dropbox.com/scl/fo/18axz1hykuvxdi6bc1b10/AASuHBq_k5GHiet5NzCznSE?rlkey=29ysnmzez2mk2mde0c4v9yfjy&st=9mtdeysz&dl=0
Madhav
Can anybody help me online working on backend of my website
Rose
That's 2/2 warnings; Vidya is banned! Reasons: 1: non-english 2: non-english
Rose
That's 2/2 warnings; Mazen is banned! Reasons: 1: nohello.com 2: nohello.com
Rose
User S G Associate has 1/2 warnings; be careful! Reason: ot, go philosophise on off topic
Engine
Hello, if you experienced TensorFlow framework for C++ (not through python), can you tell me how it works, is it better than python version and why? what are the differences? and what are the requirements?
Ludovic 'Archivist'
Hello, if you experienced TensorFlow framework for C++ (not through python), can you tell me how it works, is it better than python version and why? what are the differences? and what are the requirements?
Tensorflow for C++ is how Tensorflow for python works, it calls upon the C++ version. Differences are inexistant except you will get more control over things in C++
Ludovic 'Archivist'
I think it uses C version of tensorflow.
You mean that they linked a C++ lib through a C lib to use it from C++? I sure hope not
Ludovic 'Archivist'
The python wheel package is a tensorflow c api wrapper
Oh, makes sense, not very bright tho, whoever did that is definitely not the penguin that slides the furthest
𝘞𝘦𝘢𝘳𝘪𝘯𝘨𝘔𝘦𝘥𝘢𝘭
hello everyone! I'm making a simple window manager (testing it on Xephyr), but when I try to run any terminal (kitty, alacritty) or firefox it opens on my display=:0 not in my Xephyr. So I tested it on my hardware using a .desktop on /usr/share/xsessions, when I try to run firefox it crashes my wm, why? I'm using Xlib
𝘞𝘦𝘢𝘳𝘪𝘯𝘨𝘔𝘦𝘥𝘢𝘭
hello everyone! I'm making a simple window manager (testing it on Xephyr), but when I try to run any terminal (kitty, alacritty) or firefox it opens on my display=:0 not in my Xephyr. So I tested it on my hardware using a .desktop on /usr/share/xsessions, when I try to run firefox it crashes my wm, why? I'm using Xlib
edit: after some investigation I found out that when hovering on firefox it spawns a new window... so I made a new function like shouldmanagewindow that checks for: _NET_WM_WINDOW_TYPE_UTILITY _NET_WM_WINDOW_TYPE_POPUP _NET_WM_WINDOW_TYPE_TOOLTIP _NET_WM_WINDOW_TYPE_DIALOG using XGetWindowProperty but nothing... edit2: I should have fixed by checking for wm_transient_for...
Michel
Is it guaranteed that the order of an iteration through an unordered_map will be the same if the map is not modified between iterations? I mean, if I have: for(auto [key, _]: my_map) { // some stuff with key} for(auto [_, value]: my_map) { // some stuff with value} Will the keys keep the correspondence with the values in the order?
Vlad
I really dunno what to tell you buddy
Vlad
But it's in the name
Michel
I know it's unordered
Michel
I mean the relative order between the elements as the iterator goes
Pavel
I mean the relative order between the elements as the iterator goes
I don't think it explicitly guarantees anything about the order, but I think it is safe to assume the order will not be changed if the map is not modified.
Vlad
And not try to guess whether it will match
Vlad
Also he kinda already has the mapping you know, but tries to sorta map it in the different way
Vlad
Strong XY problem vibes
Pavel
I think it would be wiser to rewrite it in a way that takes only 1 for loop
I mean for sure, it also will create less questions from the next programmer who reads the code
Vlad
xyproblem.info
Vlad
If he really must do it in two for loops he should lock the map with mutex or something
Vlad
Nobody will remember that this code will fall apart if somebody touches the map concurrently
Michel
I mean for sure, it also will create less questions from the next programmer who reads the code
Well, I argue it's more readable the way I'm thinking. I'm doing a bit level serialization of the data where I put first the values separated by a divisor token and then the keys. I think it'll be much more cumbersome to be inserting in two places with offset in a single iteration and also will be harder for anyone else to read it. Two fors are just simpler imo. I guess I'll simple use a map instead of an unordered map, there is no much data and the map might even do better.
Vlad
One for keys one for values
Vlad
You do one preprocess step and populate them
Vlad
Then do whatever you want
Vlad
And it's also mapped 1-to-1
Vlad
It would take 2 extra allocations to store these pointers but it won't matter much for serialization since bottleneck is IO
FriedRice
If you use unordered_map, it means you don't care about the order.....You can copy the map into a vector and sort into order you want, but you don't have order in the unordered_map.
Ludovic 'Archivist'
std::unordered_map is typically good if you have large amount of data with many lookups. Otherwise it's better to go for std::map. As for your initial question, I assume since the container doesn't change during the iterations, they are going through the same path.
Unordered map is overall a terrible implementation of a lookup table in almost all cases unless you need reference stability. If you do not need reference stability, use Google's dense hash map or Malte Skarupke's bytell hashtable
Ludovic 'Archivist'
If you have the time. I recommend you watch this conference before picking a hashtable https://youtu.be/M2fKMP47slQ
Abbasi
Stroustrup, in one of his books says: Use std::unordered_map if you need to do a lot of lookups in a large map and you don’t need an ordered traversal (and if you can find a good hash function for your key type). IIRC. And hashtables have much to deal with, yeah. Will try to watch that video too.
5iiii
hey i from taiwan i want to ask few C++ question about my college project
5iiii
Someone can add my friend and talk to me?
klimi
Someone can add my friend and talk to me?
You can probably just ask your question here so all people can see it and potentially help you
5iiii
Oh ok sorry my first time