473,320 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

nonstandard type for a bit field warning

I am compiling a C application on an HP Unix 11.23 platform using the C99 compiler. I am receiving the following three warning message from the /usr/include/sys/_mbstate_t.h include file.

"/usr/include/sys/_mbstate_t.h", line 11: warning #2230-D: nonstandard type
for a bit field
unsigned char __parse_size:3;
^
"/usr/include/sys/_mbstate_t.h", line 12: warning #2230-D: nonstandard type
for a bit field
unsigned char __dummy:4;
^
"/usr/include/sys/_mbstate_t.h", line 13: warning #2230-D: nonstandard type
for a bit field
unsigned char __shift_state:1;

I understand that the c99 compiler warns the user of the use of "unsigned char". However, this is in a system include file. Is there a compiler option that will tell the c99 compiler to accept "unsigned char"? I don't want to surpress warning messages and I really don't like to ignore warning messages. Any help will be greatly appreciated.
Feb 11 '09 #1
9 7894
JosAH
11,448 Expert 8TB
If that header file comes with your C99 compiler I consider that a sloppy blooper. If not, it's not the (old) header file to blame. Bit fields can be of type (un)signed int or Bool, nothing else. If I had to work with this struct I'd check if the packing of the bits works out ok (including the warnings) and ignore those warnings if everthing works out fine. Otherwise, complain at HP.

kind regards,

Jos
Feb 11 '09 #2
Thank you for your assistance. I have both the C89 compiler and the C99 compiler. I have been using the C89 compiler for years and would like to use the C99 compiler since it seems to warn me more than the C89 compiler on potential problems. The include file listed above comes with the system. It is not one from our development team and I agree --- very sloppy.
Feb 11 '09 #3
I asked this question on the HP forum and received the following response from HP. The suggestions worked.

<begin response>
What version of aC++ are you using?
The only way you can get that warning on system include files is if you are illegally including the default include path, -I/usr/include. Remove it.

>Is there a compiler option that will tell the c99 compiler to accept "unsigned char"?

The compiler does accept it. By using c99 instead of "cc -AC99", you are asking to get that warning.
You can suppress warning 2230 with +W2230.
<end response>
Feb 12 '09 #4
Banfa
9,065 Expert Mod 8TB
Remember that by suppressing the warning all you are doing is masking the problem rather than fixing it.

The HP might accept unsigned char but by using it you are creating non-standard, non-portable code that could be an issue if your product is ever moved to another platform.
Feb 12 '09 #5
JosAH
11,448 Expert 8TB
@awagner
Cute; you're not supposed to use the standard system include files; does that compiler come with its own header files, compatible with the system header files?

kind regards,

Jos
Feb 12 '09 #6
@JosAH
Yes cute. Apparently the header files do come with the compiler. I removed the -I/usr/include and changed the "c99" compiler to "cc -AC99" as suggested in our makefiles. I did not suppress the warning. I don't like doing that.
Feb 12 '09 #7
JosAH
11,448 Expert 8TB
@awagner
I suspect that the warning is still issued? The trouble with those bitfields is packing; I suspect that this happens with unsigned char bitfiields:

Expand|Select|Wrap|Line Numbers
  1. struct {
  2.    unsigned char foo:6;
  3.    unsigned char bar:3;
  4. }
  5.  
The structure supposedly looks like this:
FFFFFFxxBBBxxxxx

i.e. 6 bits for member foo; foo is packed in a byte and field bar is packed in the next byte. OTOH I suspect the structure:

Expand|Select|Wrap|Line Numbers
  1. struct {
  2.    unsigned int foo:6;
  3.    unsigned int bar;3;
  4. }
  5.  
... to be packed as follows:
FFFFFFBBBxxxxxxx ... sixteen bits more ...

i.e. both member fields fit in a single int. You have to check how the stuff is packed while that warning is issued.

kind regards,

Jos
Feb 12 '09 #8
My apologies for not being clear. No, the warning is no longer issued after I made the suggested coding changed.
Feb 12 '09 #9
JosAH
11,448 Expert 8TB
@awagner
I guess all you can do now is check if it works, i.e. see if the packing of the bit fields is done correctly (read: as you want it to be done). Best of luck.

kind regards,

Jos
Feb 12 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Christian Seberino | last post by:
distutils question: I reset prefix to something else and happily installed everything a package I made fine. There is a warning message at end of installation about prefix not being in...
13
by: Peter | last post by:
Can anyone tell me how to change the data type of a field in a table created with a make table query? The field is a binary and must be changed to text. alternately does anyone know how to specify...
13
by: Mark A. Odell | last post by:
I write a lot of drivers and there is inevitably some hardware register or buffer descriptor field called 'flags'. The flags are defined, typically, as bit positions. I was thinking I could get...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
0
by: Scott | last post by:
I have a search form built with Access 97 and now I upgraded to Access 2003. On one field of the resulting form, I have a field of hyperlink data type containing the path of the file, i.e., Disk...
4
by: Paul Rubin | last post by:
I'm new to xml mongering so forgive me if there's an obvious well-known answer to this. It's not real obvious from the library documentation I've looked at so far. Basically I have to munch of a...
3
by: David Mathog | last post by:
I have a program for which this line: if(! lstrtol(&atoken,length-2,(long *) &(lclparams->pad)) || (lclparams->pad< 0)){ generates the warning below, but ONLY if the gcc compiler is at -O2 or...
4
by: Macneed | last post by:
i am a newbie, i remember i read a book talking about when u declare a array variable using float ABC = new float; the whole array element in ABC ( ABC to ABC ) will automatic initialize to 0...
11
tdw
by: tdw | last post by:
Hi all, I have tried a few different methods to accomplish this, but with no luck. I will post the code for the latest attempt at the end of this post. I work at a land surveying company. This...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.