Generic data types in C

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

This video is great for hobby coders like me who are looking for immediate guidance. It incorporates various C features, but beginners should not be intimidated by the code. Although CodeVault describes it as using simple data types, it's important to note that he possesses deep knowledge of C. You will gradually become accustomed to reading and understanding such code, but it requires regular practice on a daily basis.

grimvian
Автор

Making something like this typesafe would probably require either actual RTTI (and there's no RTTI in standard C) or some macro magic to make it generic. C is cool and all but without templates it might be better to write data structures for specific use cases. Anyway thanks for your videos :)

ovi
Автор

I think this is the first time he I've seen someone use C99 style structure declarations!!

sagedoesstuff
Автор

I think since enums take value and since stack_create function is type safe function, we should remove those if statements in stack_create function and add every possible data type size as value to enums. This way there is no need to add if statements and It is safe to use and there is no need to edit function, just for adding new data type. we could also use sizeof operator to get size of complex objects and store those as enum.
type enum DataType {
INT = 4,
FLOAT = sizeof(float),
...
} DataType;
Please tell me if I am wrong.

gogdarag
Автор

Why not just go all in and pass the size in bytes of the data type you want to store, instead of a limited enum, to the initialization function?

MatheusAugustoGames
Автор

why you are using this dot in 4:56, could you explain this a little bit, a see this a lot but i do not know what is the reason behid this, thank you

Antyelektronika
Автор

what about function pointers in a generic ADT that's pretty important,
functions that the user creates and can use them with our function pointers that we made in the source file, it's complicated I think you should make a video about it.
an ADT should be a header file and a source file right?
so pretty much in the header file we write:
typedef struct _stack *Stack;
also "typedef void* Element" instead of typing void* everytime.(you can name it anything you want other than Element).
in the source file the structure will look like this:
struct stack
{
size_t size;

}

amirkh
Автор

How do you have this deep knowledge of c programming. Do you use any resources to learn. If yes pls state them.

DevilRohitSingh
Автор

Hello. In this case we are stuck with the types defined above. If we want in our application to define other types of data (with structs) would we have to refactor all the code?

marmadeoli