Errors when #including <regex.h>

234 views
Skip to first unread message

Matthew Steele

unread,
Aug 25, 2010, 5:45:13 PM8/25/10
to native-cli...@googlegroups.com
I am trying to compile code that #includes <regex.h>, but I get the
following errors from nacl-g++:

/home/mdsteele/native_client_sdk_0_1_519_0/toolchain/linux_x86/bin/../lib/gcc/nacl64/4.4.3/../../../../nacl64/include/regex.h:43:
error: ‘off_t’ does not name a type
/home/mdsteele/native_client_sdk_0_1_519_0/toolchain/linux_x86/bin/../lib/gcc/nacl64/4.4.3/../../../../nacl64/include/regex.h:47:
error: ‘size_t’ does not name a type
/home/mdsteele/native_client_sdk_0_1_519_0/toolchain/linux_x86/bin/../lib/gcc/nacl64/4.4.3/../../../../nacl64/include/regex.h:53:
error: ‘regoff_t’ does not name a type
/home/mdsteele/native_client_sdk_0_1_519_0/toolchain/linux_x86/bin/../lib/gcc/nacl64/4.4.3/../../../../nacl64/include/regex.h:54:
error: ‘regoff_t’ does not name a type
/home/mdsteele/native_client_sdk_0_1_519_0/toolchain/linux_x86/bin/../lib/gcc/nacl64/4.4.3/../../../../nacl64/include/regex.h:97:
error: ‘size_t’ does not name a type
/home/mdsteele/native_client_sdk_0_1_519_0/toolchain/linux_x86/bin/../lib/gcc/nacl64/4.4.3/../../../../nacl64/include/regex.h:98:
error: ‘size_t’ has not been declared

Looking within regex.h in the standard SDK include files, I can see a
"typedef off_t regoff_t", so the issue here is only that the
definitions for off_t and size_t are missing -- apparently they aren't
defined by default and regex.h doesn't include the necessary headers
to define them. I can work around the issue by #including
<sys/types.h> in my code before #including <regex.h>, but it seems
like that shouldn't be necessary (and indeed, my code works just fine
as-is with regular g++). Is this a bug, or am I perhaps missing some
compiler flag?

I am using the latest version of the NaCl SDK (r519).

Cheers,
-Matt

Victor Khimenko

unread,
Aug 25, 2010, 6:04:22 PM8/25/10
to native-cli...@googlegroups.com
On Thu, Aug 26, 2010 at 1:45 AM, Matthew Steele <mdst...@google.com> wrote:
Is this a bug, or am I perhaps missing some compiler flag?

It's not a bug, it's POSIX 1997. Compare:

Hopefully the requirement will go away soon (when we'll port glibc to NaCl), but for now you should follow in footsteps of POSIX 1997. It'll not hurt later too :-)

Matthew Steele

unread,
Aug 25, 2010, 6:31:23 PM8/25/10
to native-cli...@googlegroups.com
On Wed, Aug 25, 2010 at 6:04 PM, Victor Khimenko <kh...@google.com> wrote:
>
> On Thu, Aug 26, 2010 at 1:45 AM, Matthew Steele <mdst...@google.com> wrote:
>>
>> Is this a bug, or am I perhaps missing some compiler flag?
>
> It's not a bug, it's POSIX 1997. Compare:
> POSIX 1997: http://opengroup.org/onlinepubs/007908775/xsh/regexec.html
> POSIX
> 2001: http://www.opengroup.org/onlinepubs/000095399/functions/regcomp.html

Aha, okay. Thanks for de-mystifying me. (-:

> Hopefully the requirement will go away soon (when we'll port glibc to NaCl),
> but for now you should follow in footsteps of POSIX 1997. It'll not hurt
> later too :-)

Gotcha. Out of curiosity, do you have any sense of when NaCl will use
glibc? I ask because I've previously run into issues where I needed a
non-standard function that glibc provides but that NaCl apparently
currently doesn't (in particular, timegm()).

Thanks,
-Matt

Reply all
Reply to author
Forward
0 new messages