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

Type of argv parameter #19

Closed
jibsen opened this issue Jan 26, 2016 · 3 comments
Closed

Type of argv parameter #19

jibsen opened this issue Jan 26, 2016 · 3 comments

Comments

@jibsen
Copy link
Collaborator

jibsen commented Jan 26, 2016

The rule that allows you to pass a pointer to a function that expects a const pointer is only applied at top level, so if you try to pass an argv declared in the standard way (char *argv[]) to munit_suite_main, GCC will warn about it.

@nemequ
Copy link
Owner

nemequ commented Jan 26, 2016

Interesting. I wonder if const char* const* (on munit_suite_main) would work… Based on that page I don't think so, but it's worth a try. I'll play around with it this afternoon.

@jibsen
Copy link
Collaborator Author

jibsen commented Jan 26, 2016

It believe it would work in C++, but in C I think char *const * is the best you can hope for if you wish to be able to pass a char ** without a warning or a cast.

It's not a big deal, just an oddity of C really .. but it would perhaps be preferable if the standard type could be passed without warnings.

nemequ added a commit that referenced this issue Jan 26, 2016
@nemequ
Copy link
Owner

nemequ commented Jan 26, 2016

Yeah, I think you're right, char * const * is the best we can do. const is one of the things that C really gets wrong IMHO (most of the other issues I have are really problems with the standard library, not the language).

@nemequ nemequ closed this as completed Jan 26, 2016
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

2 participants