Manav
For fun and my_function there's no argument.
Manav
You can see the mangled names, <...> this becomes a part of the function name so we can simplify the signatures fun2 => void name(void (*)()) void fun => void name() void my_function => void name() void
Manav
I hope that clears your doubts, go through this as well: https://katb.in/omipulufobi
Manav
I hope that clears your doubts, go through this as well: https://katb.in/omipulufobi
Here you can see the calls happen using the pointer stored on stack. [rbp - 8] in both cases. However in one case (fun2) the function is passed as an argument in the form of a pointer. And in the other case (fun) the function is taken from the outer scope
Racing D
hi guys , what will be the output of this program written in c : #include <stdio.h> #define f(a, b) a+b; #define g(a, b) a*b; int main() { // Write C code here int Y; Y = 2*f(4, g(3, 5)); printf("Y = %d", Y); return 0; }
Racing D
plzz help ?
Racing D
what will be the output
Racing D
This sounds like a homework question
the compiler gave me 23 , but when i did it manually it gave me 38 , i dont know how the compiler did it ?
Racing D
can u explain it in deta
Racing D
plz
Racing D
even we use float, the result will not change
...
even we use float, the result will not change
#include <stdio.h> int f(int a, int b){ return a+b; }; int g(int a, int b){ return a*b; } int main() { // Write C code here int Y; Y = 2*f(4, g(3, 5)); printf("Y = %d", Y); return 0; }
...
even we use float, the result will not change
Thisthe result of this turns out to be correct
...
#include <stdio.h> template<typename T> T f(T a, T b){ return a+b; } template<typename T> T g(T a, T b){ return a*b; } int main() { // Write C code here int Y; Y = 2*f(4, g(3, 5)); printf("Y = %d", Y); return 0; }
klimi
The execution order of parameters is not defined in C
klimi
Also sounds like homework
...
Also sounds like homework
it seems so to me too
Racing D
yes i agree , sounds be correct but why when i use the first program , it didn't work "im begineer "
Racing D
#define f(a, b) a+b; #define g(a, b) a*b; with these macros
klimi
Oh right you are using macros... That's even more wrong
Racing D
but when i compile it , it worked
Racing D
with macros
Racing D
thanks anyway guys !
Simple Sorcerer
small question on threads POSIX. what is guard_size ? is it extra space if there is not enough stack size ?
Simple Sorcerer
The pthread_attr_setguardsize() function sets the guard size attribute of the thread attributes object referred to by attr to the value specified in guardsize. If guardsize is greater than 0, then for each new thread created using attr the system allocates an additional region of at least guardsize bytes at the end of the thread's stack to act as the guard area for the stack (but see BUGS).
VD
The pthread_attr_setguardsize() function sets the guard size attribute of the thread attributes object referred to by attr to the value specified in guardsize. If guardsize is greater than 0, then for each new thread created using attr the system allocates an additional region of at least guardsize bytes at the end of the thread's stack to act as the guard area for the stack (but see BUGS).
It is to make sure that your thread doesn't read memory that it is not supposed to access. Suppose say your thread allocates a buffer on the stack and due to some bug in your code you read past the array and enter the guard area, your code would terminate immediately thus exposing the problem then and there rather than causing Undefined Behavior and a failure somewhere else
Ziky
small question on threads POSIX. what is guard_size ? is it extra space if there is not enough stack size ?
No it is just space of constant value at the end of your stack. If thread overwrites this data thread will get SIGSEGV signal. It doesnt prevent you from reading anything in memory alocated to proccess your thread (s) is/are living in nor allocation of something big. Just If you will be lucky enough to overwrite guard part you will get that signal.
Ziky
About the failure elsewhere. Doesn't the kernel control access to RAM or is this possible in root in linux?
Root is just user... Each process can read/write only its own assigned memory. A process consists of one more more threads which shares the same memory space = any thread can access to every piece of memory assigned to its process. But we are drifting offtopic. google for process / thread difference or for memory mapping unit if you are curious how it works under the hood.
Bala
I need C++ support
Bala
Is there any one
Luca
Please explain problem
suraj
I need C++ support
Just post your problem
Viking
Curtailed list of c++ advanced level interview questions for brush up pls... Can some one share best links or pdf's that they come across??
Anonymous
I would need a dev would help me at suitable cost tho
Ighor
@belousotroll don’t ask for help in the first ever message in this group
Владислав
Oh.
Владислав
Ighor
How should I build communication in this group?
that is enough, you can post the message again
Владислав
Thank you.
Владислав
link: https://godbolt.org/z/Evrcde6zz I want to learn how to build SQL queries at compile-time. I have already taught my library to retrieve values correctly by name using schema.get<field_name>(index). The remaining challenge is to learn how to construct SQL queries. The problem with composing queries is that at the point of writing aliases, I need to both prepare the queries, insert them into field names, and select the result type of this query. For nested queries with different transformations, it requires duplicating variables with almost identical queries. Or perhaps there are existing patterns that are well-suited for solving my problem? Even in the current implementation, an interface with frequent use of 'using _1 = ...; using _2 = ..<_1>; ...' looks cumbersome. mb something like this, but how...: using ModifiedMessageTable = ModifySequence<MessageTable, Modifier<message_id, mod::toString<>, mod::argMax<message_event_time>>, Modifier<message_event_time, mod::toString<>>, Modifier<message_body, mod::toHex<>> >::type;
Bala
Suggest me C++ app
Владислав
No, I meant something else: can you help me determine the direction in which it is worth developing in this matter? I mentioned the problem: with the current architecture, I would have to constantly use "using _(N...);". If you have encountered a similar problem and/or implemented something similar, can you suggest how you solved this issue? For example, one of the solutions I see is to use Boost::Hana, which allows manipulating types as if they were values. However, since I have no experience with the library, I have a weak understanding of when and under what circumstances it would be appropriate to use Boost::Hana and whether it is suitable for the current problem. Or... is using Boost::Hana an excessive solution, and are there simpler mechanisms for addressing this issue? So, in essence, I need to implement a type conversion pipeline while preserving the original type. This seems to be a fairly common use case. If there are any pitfalls, I would appreciate hearing about them from more experienced colleagues.
klimi
Suggest me C++ app
add some context to your query and I might help ya
Bala
add some context to your query and I might help ya
I want to know C++ in depth and theory wise i am not strong . Suggest me which website is better compared to other websites
klimi
I want to know C++ in depth and theory wise i am not strong . Suggest me which website is better compared to other websites
so now you don't want any c++ app and you want comparison of websites? cppreference is the best
三体183号
Okay tq
Suggest watching some videos
Pippi
I want to know C++ in depth and theory wise i am not strong . Suggest me which website is better compared to other websites
You have to choose a niche. Then concentrate on that niche. It may be game development, App development and so on
Pippi
And how do we choose a niche?
Why do you want to learn programming?
Gaaaaaaa
is there any small project , to work with? I need learn by project. In c++. Unpaid is okay
Kenshin
is there any small project , to work with? I need learn by project. In c++. Unpaid is okay
Visit GitHub, search for a simple project that piques your interest, contribute.
Abdulmatin_OG
Why do you want to learn programming?
Firstly I'm studying computer science and I want to be ahead of the class, secondly I don't really have prior experience on it and I really have interest in it
DC
And how do we choose a niche?
It’s depend on what do you want to learn or masters. You have to choose more specific niche such as front end or back end developer or maybe an iot software developer which is more specific and require a specific skill and knowledge.
DC
Well I started with C and html but for some reason I had to learn python and django
So you want to focus more on python and django which is web development? Than focus on those only and any framework that related to the web development using python and also database. Don’t learn about anything that doesn’t relate to web development. Just be focus.
DC
So I should just focus on web development at the moment
Ya, become an expert. Don’t waste your time by trying to master everything in programming, it’s like an ocean.
Abdulmatin_OG
I can use that to do data analysis?
klimi
I can use that to do data analysis?
depends what part of data analysis you want to do, with python you will have good foundation
Abdulmatin_OG
DC
Oh ok thank you but it would be better if I can get like tips and pointers
It’s better for you to get more wide pov of python first. I mean like the map off python and it’s applications. Than you will know exactly on what you have to learn.
Mohamed
What is the best site for learning topics of c++
Chat Boss
Владислав Белоусов sent a huge message, it has been re-uploaded as a file I have an architectural question: I'm trying to separate the domain part in the architecture of ..
Владислав
I have an architectural question: I'm trying to separate the domain part in the architecture of my application, which receives data through FlatBuffers. It describes many structures, like these: table MyTable { field_1:[uint8]; field_2: OtherTable; field_3: uint; field_4: uint; } Should I duplicate the field definitions in the Entity part and then map them to the structures? I feel uncomfortable with unnecessary duplication, but the Entity should not be aware of FlatBuffers, etc. However, if FlatBuffers are the only channel for receiving data of this type, what should I do?
Владислав
TBH I dont know exactly what do you mean by flat buffers but it sound like PIMPL might be what you need
it's like protobuf. Binary protocol to communicate with internal services. PIMPL is about to cover implementation, it's just another dimension.
Владислав
I receive data using the FlatBuffers protocol. I need to process this data in the business logic layer and then save it to a database. The question is: would it be a good practice to create an entity in the Entity layer for an independent data representation? If an answer is yes, why? No? Why.
Владислав
Currently, it works like this: I receive data in FlatBuffers, and some fields are optional. Unpacking the data is also problematic, as I need to validate pointers for null values. When saving these complex nested FlatBuffers structures to a database, I have to write a lot of code for validation and transformation. If I introduced an additional layer (Entity) and described the entity using standard structures, it would be easier to work with it in other parts of the application. This is the "Clean Architecture" pattern.