Legal Ways To Call Void Functions | C Programming Tutorial
Вставка
- Опубліковано 8 вер 2024
- Learn about the different legal ways to call void functions in C. This video is mostly just for fun as the unusual but still legal ways that we can call void functions are either not useful or generally considered bad practice. Source code: github.com/por.... Check out www.portfolioc... to build a portfolio that will impress employers!
For the sake of completeness ...
you can have a variable of type 'pointer to function returning void',
assign your void function to this pointer (which basically copies the entry address of the function into the pointer)
and finally call the function via the pointer.
That’s true! :-) Anyone interested in learning about this may find this video on function pointers interesting: ua-cam.com/video/f_uWOWViYc0/v-deo.html
I think if you are writing a wrapper around a void function it might be better practice to do "return func();" because if the definition of func() changes to output a type then you want a compiler error
void func() {}
#pragma startup func
#pragma exit func
gcc:
void __attribute__((constructor)) func();
void __attribute__((destructor)) func();
Not sure if it counts because it depends on the compiler.
Hello sir, could you make a playlist on implementing data structures in c exactly like we use stl in c++
like for example we have to declare the size of array beforehand for stack implementation using arrays in c. But like the stl works we don't need to provide the size before using the stack. I want this for all data structures. Thank you and awesome content
Thank you so much for making these videos.
You’re very welcome! :-)
May i ask , what editor are you using ?
Xcode on MacOS :-)
Didn't know about the bracket operation
Thank you
You're welcome! :-)
Appreciate the explanation. Can you make a video about global variables. Thank you again❤❤❤
Yes, this video should cover them: ua-cam.com/video/qXVIMX2GlK8/v-deo.html
And you might like this one too on sharing a global variable "across files": ua-cam.com/video/Wqm1tSzmqkY/v-deo.html
, operator has defined order of execution now?
Yep, always has been. It has undefined order of execution when calling functions, like passing parameters to it.
Yes that's correct, when calling functions it's technically being used as a "separator" and not as an "operator". That may actually be a good video topic, to make that clear...
Can you please explain thread all functions in library threads
Thank you for the suggestion. :-)
Thanks i didn't know that was a thing thank
You're welcome! :-)
that was pretty useless, but fun
Road to 200k ⏩
:-)
The only thing holding him from 10,000,000 subscribers is light theme
Looks like 200K has been achieved 👍
return function1(), 0;
Wow someone is using vanilla C in 2024 😮
C forever! :-)
C is almost the de facto programming language in embedded systems.