classification
Title: compile error on HP-UX 11.22 ia64 - 'mbstate_t' is used as a type, but has not been defined as a type
Type: compile error Stage:
Components: Build, Unicode Versions: Python 3.1
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: loewis, srid (2)
Priority: Keywords

Created on 2009-05-11 21:24 by srid, last changed 2009-07-02 19:15 by loewis.

Files
File name Uploaded Description Edit Remove
config.log srid, 2009-06-29 22:47
pyconfig.h srid, 2009-06-29 22:47
wchar.h srid, 2009-06-29 22:49 /usr/include/wchar.h
_mbstate_t.h srid, 2009-07-02 18:24 #include <sys/_mbstate_t.h>
test.c.preprocessed.txt srid, 2009-07-02 18:25 preprocessed output of test program using mbstate_t
test.c_XOPEN_SOURCE_500_preprocessed.txt srid, 2009-07-02 18:29 preprocessed with -D_XOPEN_SOURCE=500
Messages (7)
msg87588 - (view) Author: Sridhar Ratnakumar (srid) Date: 2009-05-11 21:24
cc +DD64 -Ae -D_REENTRANT +Z -c  -DNDEBUG -O  -I. -IInclude -I./Include
  -DPy_BUILD_CORE -o Modules/python.o ./Modules/python.c
Error 419: "./Modules/python.c", line 34 # 'mbstate_t' is used as a
type, but has not been defined as a type.
            mbstate_t mbs;
            ^^^^^^^^^     
make: *** [Modules/python.o] Error 2


!
!
!

When I get time, I need to create a patch to fix this.. but if somebody
else already figured out what the issue is, that'd be great too.
msg87649 - (view) Author: Sridhar Ratnakumar (srid) Date: 2009-05-12 18:25
Adding Martin to the nosy list as this is related to his change:
Modules/python.c?view=annotate#l17">http://svn.python.org/view/python/branches/py3k/Modules/python.c?view=annotate#l17
msg87653 - (view) Author: Martin v. Löwis (loewis) Date: 2009-05-12 18:38
I have two questions:
1. does your system provide the mbstate_t type?
2. if so, what header file needs to be included?

Also, please confirm a few things:
a. configure has detected that your system has mbrtowc
b. configure's analysis is correct, i.e. your system has mbrtowc indeed.
msg89890 - (view) Author: Sridhar Ratnakumar (srid) Date: 2009-06-29 22:46
Hello Martin,

My apologies for responding so late.


[Martin] Also, please confirm a few things: a. configure has detected 
that your system has mbrtowc (...)

# Yes, as can be seen in the attached config.log

[Martin] (...) b. configure's analysis is correct, i.e. your system has 
mbrtowc indeed.

# Yes, `mbrtowc` is present as the following C programs compiles and 
runs successfully:

  #include <wchar.h>
  int main()
  {
    printf("Init\n");
    mbrtowc(NULL, "", 1, NULL);
  }

[Martin] does your system provide the mbstate_t type? if so, what 
header file needs to be included?

`mbstate_t` seems to exist in /usr/include/wchar.h .. however, 
including <wchar.h> does not seem to work:

bash-2.04$ cc +DD64 -Ae -D_REENTRANT +Z --version              
cc: HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]
bash-2.04$ cat test.c
#include <wchar.h>
int main()
{
  mbstate_t foo;
  printf("Init\n");
  mbrtowc(NULL, "", 1, NULL);
}
bash-2.04$ cc test.c -o test                     
Error 419: "test.c", line 6 # 'mbstate_t' is used as a type, but has 
not been defined as a type.
      mbstate_t foo;
      ^^^^^^^^^     
bash-2.04$ aCC test.c -o test
Error 403: "test.c", line 8 # Undeclared variable 'mbrtowc'. Perhaps 
'mbtowc' as in "int mbtowc(wchar_t *,const char *,unsigned long)" ["/
usr/include/stdlib.h", line 169] was intended.
      mbrtowc(NULL, "", 1, NULL);
      ^^^^^^^   

cf. http://www.mail-archive.com/lftp-devel@uniyar.ac.ru/msg00602.html
msg89906 - (view) Author: Martin v. Löwis (loewis) Date: 2009-06-30 05:38
> `mbstate_t` seems to exist in /usr/include/wchar.h

I can't infer that from the copy of wchar.h that you provided. I
see that mbstate_t* is used, but I fail to find any definition
of mbstate_t.

I see that sys/_mbstate_t.h is included. This inclusion is conditional
on  _INCLUDE__STDC_A1_SOURCE, so a first check should be done whether
this is defined. In addition, it would be interesting to know what
_mbstate_t.h contains.

> bash-2.04$ cat test.c
> #include <wchar.h>
> int main()
> {
>   mbstate_t foo;
>   printf("Init\n");
>   mbrtowc(NULL, "", 1, NULL);
> }

It's best to focus on this example. Produce preprocessor output for
it, and attach that to the bug report.

This is standard C, AFAICT, so if the compiler fails to compile
it, something is wrong with the compiler, or you are using it incorrectly.

As a wild guess, try defining _XOPEN_SOURCE to 500, i.e.
-D_XOPEN_SOURCE=500.

> cf. http://www.mail-archive.com/lftp-devel@uniyar.ac.ru/msg00602.html

I don't think this is relevant. Somehow, they managed to #define
mbstate_t to int, breaking the header - this should not happen here.
msg90030 - (view) Author: Sridhar Ratnakumar (srid) Date: 2009-07-02 18:27
I've attached the files you requested.

> As a wild guess, try defining _XOPEN_SOURCE to 500, 
> i.e. -D_XOPEN_SOURCE=500.

Yes, this works .. the file compiles. I tried modifying the value of 
_XOPEN_SOURCE to 500 in pyconfig.h (currently set to 600). While fixes 
the mbstate_t error .. it results in in-numerous other errors.
msg90033 - (view) Author: Martin v. Löwis (loewis) Date: 2009-07-02 19:15
> Yes, this works .. the file compiles. I tried modifying the value of 
> _XOPEN_SOURCE to 500 in pyconfig.h (currently set to 600). 

That's an HPUX bug then, please report it to HP. They should assume
that any feature present in XPG 5 is also present in any later version.

> While fixes 
> the mbstate_t error .. it results in in-numerous other errors.

Well, we absolutely need mbstate_t, so we need to resolve all these
other errors.

Please be prepared for this becoming a many-months project. I don't
know what you need the HP-UX port for - maybe it would be best to hire
somebody who knows HP-UX, C, and Python.
History
Date User Action Args
2009-07-02 19:15:30loewissetmessages: + msg90033
2009-07-02 18:29:25sridsetfiles: + test.c_XOPEN_SOURCE_500_preprocessed.txt
2009-07-02 18:27:53sridsetmessages: + msg90030
2009-07-02 18:25:35sridsetfiles: + test.c.preprocessed.txt
2009-07-02 18:24:56sridsetfiles: + _mbstate_t.h
2009-06-30 05:38:15loewissetmessages: + msg89906
title: compile error on HP-UX 11.22 ia64 - 'mbstate_t' is used as a type, but has not been defined as a type -> compile error on HP-UX 11.22 ia64 - 'mbstate_t' is used as a type, but has not been defined as a type
2009-06-29 22:49:20sridsetfiles: + wchar.h
2009-06-29 22:47:20sridsetfiles: + pyconfig.h
components: + Unicode
2009-06-29 22:47:01sridsetfiles: + config.log

messages: + msg89890
2009-05-12 18:38:56loewissetmessages: + msg87653
2009-05-12 18:25:20sridsetnosy: + loewis
messages: + msg87649
2009-05-11 21:24:33sridcreate