Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structures ending with _t #4

Closed
clintonyeb opened this issue Sep 7, 2017 · 4 comments
Closed

Structures ending with _t #4

clintonyeb opened this issue Sep 7, 2017 · 4 comments

Comments

@clintonyeb
Copy link

clintonyeb commented Sep 7, 2017

I presume you have a lot of coding experience. I don't know why but you append all the names of your structures with _t, example:

enum MetaCommandResult_t {
 META_COMMAND_SUCCESS,
 META_COMMAND_UNRECOGNIZED_COMMAND
};
typedef enum MetaCommandResult_t MetaCommandResult;

and then later redefine it.

Is there any advantage to doing this?

@cstack
Copy link
Owner

cstack commented Sep 7, 2017

Hi,

The reason I do this is the compiler I'm using requires that whenever you reference a struct or enum you use the struct or enum keyword. (e.g. enum MetaCommandResult_t). I immediately create a typedef so I don't have to use the keyword.

@clintonyeb
Copy link
Author

Thank you for your awesome work!. I think you can close the issue now 😄

@cstack cstack closed this as completed Sep 8, 2017
@shubham1172
Copy link

Hey, I wonder why can't we just do this

typedef struct {
    char* buffer;
    size_t buffer_length;
    size_t input_length;
} InputBuffer;

Will save an extra line of code and will be as efficient I guess.

@cstack
Copy link
Owner

cstack commented Jun 22, 2019

@shubham1172 Awesome! I went ahead and made that change #37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants