possible include file problem

Started by perlmaster, November 17, 2012, 08:36:45 PM

Previous topic - Next topic

perlmaster

Hello,

I am new to Pelles C. I tried to compile a simple regex program and received the following error message

Building regex1.obj.
C:\junk\regex1.c(15): error #2048: Undeclared identifier 'regex_t'.
C:\junk\regex1.c(15): error #2001: Syntax error: expected ';' but found 'expression'.
C:\junk\regex1.c(15): error #2048: Undeclared identifier 'expression'.


(Note that there were more error messages, and all were due to the fact that "regex_t" was not defined)

If you note the 1st part of my source code below, you will see that "regex.h" is included. Why isn't regex_t defined ?

     1   #include   <stdio.h>
     2   #include   <stdlib.h>
     3   #include   <string.h>
     4   #include   <regex.h>
     5   #include   <errno.h>
     6   #include   <stdarg.h>
     7   
     8   int main(int argc, char *argv[])
     9   {
    10      int      length , argnum;
    11      char   *argptr , pattern[1024] , prematch[1024] , matched[1024];
    12      char   postmatch[1024];
    13      int      errcode;
    14      char   errmsg[256];
    15      regex_t   expression;
    16      regmatch_t   pmatch[2];
    17   

frankie

"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

perlmaster

As noted on line 4, I already have an "include" for regex.h

CommonTater

Quote from: perlmaster on November 17, 2012, 08:36:45 PM
I am new to Pelles C. I tried to compile a simple regex program and received the following error message

Ok, a little thing to know about Pelles C ... Most functions and types that are not "Standard C" (C99 or C11) are prefixed with underscores... So the actual type is _regex_t    and the functions in the regex.h  are _regcomp(), _regerror() etc. 

Look up the regex.h header in the help file (press F1) ... you'll see what I mean.

In Project-> Project options -> Compiler there is an option to "Enable Compatibility Names" which allows you to go without typing the underscores in many cases... but IMO it's better to have these functions marked in your source code since they may not be present for other standards compliant compilers.

Another hint you can take is that if you don't have it right, the syntax highlighter won't colour it.

perlmaster

Much thanks.  That solved the problem.   I should have guessed that one !  (oh for the shame of it all   :D)