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

warning: type of bit-field 'dzg_meter' is a GCC extension #69

Closed
devZer0 opened this issue Apr 10, 2019 · 6 comments
Closed

warning: type of bit-field 'dzg_meter' is a GCC extension #69

devZer0 opened this issue Apr 10, 2019 · 6 comments

Comments

@devZer0
Copy link

devZer0 commented Apr 10, 2019

src/sml_list.c:124:2: Warnung: Typ des Bitfeldes »dzg_meter« ist eine Erweiterung des GCC [-Wpedantic]
u8 dzg_meter:1;
^
src/sml_list.c:124:2: warning: type of bit-field 'dzg_meter' is a GCC extension [-Wpedantic]
u8 dzg_meter:1;
^

@andig
Copy link

andig commented Apr 11, 2019

Should be a uint8 or simply uint?

@devZer0
Copy link
Author

devZer0 commented Apr 11, 2019

i'm not good at c-programming, but isn't that struct simply meant so carry some flag to simply store some tiny bit of information if some workaround needs to be applied again or not?

don't know what correct datatype is correct for this, i would have chosen some "bool" but not some special type which generates some compiler warning.

so i think unsigned int would be ok here and makes the compile warning go away.

should i send a pull request ?

@devZer0
Copy link
Author

devZer0 commented Apr 11, 2019

by reading this, i think you are correct and "unsigned int" is correct when using bit-field:

https://www.tutorialspoint.com/cprogramming/c_bit_fields.htm

so

struct workarounds {
        u8 dzg_meter:1;
};

should be


struct workarounds {
        unsigned int dzg_meter : 1;
};

devZer0 pushed a commit to devZer0/libsml that referenced this issue Apr 11, 2019
@devZer0
Copy link
Author

devZer0 commented Apr 14, 2019

this can be closed after merging the pull request

@andig
Copy link

andig commented Sep 22, 2019

Bzw.: sollte das nicht lieber ein uint8_t sein (https://stackoverflow.com/questions/22842707/size-of-uint8-uint16-and-uint32#22843368) damit es wirklich 8-bittig bleibt? Oder ist uns das egal?

@devZer0
Copy link
Author

devZer0 commented Feb 21, 2020

could you also close this one @andig ? (as i see that my fix proposal has been merged)

sorry, i did not see your question and i cannot answer, as my c-skills are not good enough

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