Anonymous
So it's not in C++
Message from @anondrum https://stackoverflow.com/questions/776283/what-does-the-restrict-keyword-mean-in-c
/
#include <stdio.h> int foo(int * restrict a, int * restrict b) { return *a + *b; } int main(void) { int a = 1, b = 1, c; c = foo(&a, &b); printf("c == %d\n", c); return 0; }
/
help
Anonymous
in this function if a and b where already pointers in main will it be a valid usege
The point of restrict keyword is to help the compiler with optimisations. It doesn't matter where you create the pointers. As long as the pointers point to non overlapping memory regions and as long as there are no other pointers active currently to the said memory region, you can pass them in to a function which expects such pointers.
Anonymous
when you pass the pointer to the function you are giving it a copy of the pointer on the other function
But when it is passed into the function, is there a way for the calling function to modify the pointers at the same time?
/
But when it is passed into the function, is there a way for the calling function to modify the pointers at the same time?
is the restrict keyword telling that what the pointer points will not be modified by another existing pointer while the one you are using is alive
Anonymous
no i think
There you go. So using restrict for such cases is fine. Only when you have pointers that can concurrently/parallely modify the same memory region or if these pointers are to overlapping memory regions, the use of restrict may lead to Undefined Behavior.
Anonymous
so if you have two pointers that point the same memory in two parts of the program but dont modify the memory in the same time it is fine?
Restrict is a hint to the compiler to enable optimizations. So if you as a programmer are sure that at any particular point of time only one pointer is actively in use for the memory region covered by the pointer, then you can safely use restrict keyword to help the compiler further. However if this is not the case, the use of restrict can lead to Undefined Behavior. Moreover, modifying a memory location concurrently/in parallel without any synchronisation/atomicity will lead to Undefined Behavior anyway irrespective of whether you use restrict keyword or not. There is a term for this - Data Race
noalcoholatwork
@anondrum
sorry I was just trying to fool around, I don't even know about the topic, was experimenting with ChatGPT, apologies :)
noalcoholatwork
How does this community rate "The Cherno (youtube)" though? I've watched his work on youtube and I'm very impressed bu his detailed videos on C++ internals.
/
When i call a struct struct s {} and struct {} s i know that struct s {} is the struct name but what is the struct name for
/
after knowing what is the struct name for i be ready and i will compile twrp
/
but i first need to know what is repo sync for
Anonymous
How does this community rate "The Cherno (youtube)" though? I've watched his work on youtube and I'm very impressed bu his detailed videos on C++ internals.
I just checked out this channel for the first time. And I started with a random video - static. He mentions that static is used to restrict external linkage and this guy does not mention anonymous namespaces anywhere else in that video. I checked the playlist to see if there is any video on that and the one on namespaces doesn't talk about anonymous and inline namespaces either. That tells me that this guy does not necessarily understand/cover the breadth of topics that a good book mentioned in the Resources section covers. So that might not be a great channel.
Danya🔥
after knowing what is the struct name for i be ready and i will compile twrp
I'm not gonna answer to you, don't write to me
Pavel
When i call a struct struct s {} and struct {} s i know that struct s {} is the struct name but what is the struct name for
struct A {}; - declare a struct named A struct {} A; - define a variable of type a struct (the struct itself is unnamed) https://wandbox.org/permlink/ClEHdow22Jc2MHdM
Pavel
yes i know that but what is the struct name for
To declare variables of this struct or refer to it when a type is needed A a; - variable of type A (which is a struct)
Danya🔥
and why you dont want to answer me
Because instead of reading a book you asking stupid questions in the chat repeatedly
Pavel
A can be a type if it is the name of the struct?
In C++ yes, in C I'm not sure if there are "types" in the same sense.
Anonymous
It's a good channel yet as you mentioned he doesn't cover the breadth of topics
It maybe. There is no way I can pass judgement on the channel without watching a majority of his videos. Just wanted to highlight that a good book would definitely be a better alternative.
/
if it is not to make a type
labyrinth
what does it mean to have a space here: template <typename T> T get(const Field& field) { return field.template get<T>(); }
labyrinth
After template? Doesn't mean anything (a matter of code style)
what does this snippet do then? Sorry i have not read a book about c++ yet and i cant find it on google
Anonymous
what does this snippet do then? Sorry i have not read a book about c++ yet and i cant find it on google
The template keyword there just informs the compiler that what follows is a template method so that the parser does not parse the angle brackets as less than or greater than symbol and generate an error. As for what the snippet does, it just calls a template member function get on the field object and returns the value.
Petro
Hello guys, I want to start learning C, Could someone give me some recommendations about resources, books, roadmaps etc. where i get completely knowledge? I want start from fundamentals and deep diving into C. Thanks for your attention)
Petro
Why C and not C++?
On my opinion C is more powerful and gives you freedom to build something from 0 1, and because C++ written on C. Maybe I'm wrongs...
Danya🔥
And C++ more powerful
touhou
Hello guys, I want to start learning C, Could someone give me some recommendations about resources, books, roadmaps etc. where i get completely knowledge? I want start from fundamentals and deep diving into C. Thanks for your attention)
The C Programming Language by Dennis M.Ritchie and Brian W. Kernighan Modern C by Jens Gustedt Also practice, practice, practice, try problems on LeetCode, HackerRank, look at other's solutions/code etc..
Petro
C++ is not written on C
On which language written and why more powerful?
W
on my opinion, Learning C language is conducive to understanding the underlying operating system
Danya🔥
On which language written and why more powerful?
C++ is written in English: https://eel.is/c++draft/
Ehsan
On which language written and why more powerful?
c++ standard compiler is written in c++
Pavel
On which language written and why more powerful?
1) C and C++ are defined by their standards not by code, compilers implement the standard 2) from the compilers GCC and clang are written in C++ as far as I know (not sure about other compilers) 3) "powerfulness" here needs a definition, there's nothing that you can't do in one language that you can in the other in practice (C++ has more features, but C also has a couple of features that C++ doesn't have)
Pavel
c++ standard compiler is written in c++
What is "C++ standard compiler"?
Ehsan
What is "C++ standard compiler"?
compilers *, like clang++(clang for c++) and g++ (gcc for c++)
An
Under "powerful" I means that is with C I can build everything (like OS, microcontroller programming, create new programming language). I haven't knowledge about C/C++ and that is why I asking for community recommendations about learning
While we are talking about new programming languages, It seems to be fun except this one issue.. how to make a parser that turns a code from your language to exe like other compiled language? Have been struggling with this.
Mohamed
hey guys i have problems with make command in Vs code
Mohamed
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
💰💵⚛️💹⚛️💵💰
💰💵⚛️💹⚛️💵💰
Hello guys, I want to start learning C, Could someone give me some recommendations about resources, books, roadmaps etc. where i get completely knowledge? I want start from fundamentals and deep diving into C. Thanks for your attention)
depending what's your target, e.g : if your target is to build app in windows, you can learn basic C programming book that you can find in the book stores and then continue to learn C with Win32, for C with Win32 you can use Charlez Petzold Win32 programming book or Herbert Schild or other authors regarding C Win32 programming but to enter C Win32 programming u must have strong understanding about array, struct and pointer once u learn C Win32 u will find windows specific data types that can make trainee confuse. to overcome this case, u must have MSDN documentation to help you understand C Win32 data types, windows functions, struct member, union member, etc
Anonymous
How can i use "EOF" using a emulator in an android phone?
Chat Boss
Alex sent a code, it has been re-uploaded as a file
Light
Alex sent a code, it has been re-uploaded as a file
beecrowd | 2138 what is the problem with my code? I have checked input output are the same but showing wrong answer
Anonymous
beecrowd | 2138 what is the problem with my code? I have checked input output are the same but showing wrong answer
Input size is specified as 1000 digits clearly in the problem. In your code you use an array of size 100 to read the input. 🤦‍♀
Ardo
Hello guys. Good afternoon from my country in indonesia.. Kindly, im facing a quite stressing ridiculous problem here.. Any suggest for installing compiler for c++ in windows 11? i can't Compile anything with every famous IDE
Danya🔥
c++ standard compiler is written in c++
There is no standard c++ compiler
Chat Boss
andriiko489 sent a huge message, it has been re-uploaded as a file long int getcode(price prices[], int numprices) { bool b = 0; unsigned long long code; whi..
andriiko489
andriiko489 sent a huge message, it has been re-uploaded as a file long int getcode(price prices[], int numprices) { bool b = 0; unsigned long long code; whi..
"Size mismatch: 'unsigned __int64' passed as _Param_(4) when 'int' is required in call to 'printf'." at line 165, how to solve this problem? UPD: I found problem, thx!
Анвар
Hi, can someone suggest fast postgresql drivers/api with pooling c++?
Chat Boss
Alex sent a code, it has been re-uploaded as a file