[ragel-users] Error: need explicit cast to convert from: int (*C func)(int ) to : char const *

Adrian Thurston thurs... at cs.queensu.ca
Wed Apr 9 17:26:43 UTC 2008


Do you have

using std::eof;

or something similar in your program? The compiler seems to be resolving
"eof" to something other than the char* that is needed in 6.X. You
should just be able to add:

const char *eof = 0;

after the declaration of pe and make the error go away.

-Adrian

Bob Paddock wrote:
>  
> I  assume I have something wrong in my Ragel source file,
> but no idea where to look from this error message.
> 
> Can anyone shed any light on what this error message means?:
> 
>  if ( p == eof )
>                ^
> BootLoaderStateChart.cpp(713) : Error: need explicit cast to convert
> from: int (*C func)(int ) to  : char const *
> --- errorlevel 1
> 1 error, 0 warnings
> 
> [p or eof are pointers to functions??  I did not declare eof, was not
> using it.]
> 
> If I leave out "%% write exec;" I don't get the error.
> 
> The line number of cpp(713) seems to be completely bogus.
> My Ragel file is not that long, and line 713 of .cpp
> isn't anywhere near the offending "p == eof".
>  
> My Code:
> 
> int BootLoaderStateChart::Execute( const uint8_t *data )
> {
>   const char *p  = (const char *) data;
>   const char *pe = p+1;
> 
>   if( (cs == BootLoaderStateChart_error) ||
>       (cs == BootLoaderStateChart_first_final)
>     )
>     {
>       return -1; /* Error */
>     }
> 
>   %% write exec;
> 
>     if ( cs == BootLoaderStateChart_error )
>      {
>       return -1; /* Error */
>      }
> 
>     if( cs >= BootLoaderStateChart_first_final )
>      {
>       return 1; /* Matched */
>      }
> 
>     return 0; /* No Match */
> }
>  
> Ragels Code:
> 
> #line 479 "BootLoaderStateChart.rl"
>  {EEPROMFileSize_u16 = 4096;}
>  break;
> #line 708 "BootLoaderStateChart.cpp"
>   }
>  }
> 
> _again:
>  if ( cs == 0 )
>   goto _out;
>  if ( ++p != pe )
>   goto _resume;
>  _test_eof: {}
>  if ( p == eof )
>  {
>  const char *__acts = _BootLoaderStateChart_actions +
> _BootLoaderStateChart_eof_actions[cs];
>  unsigned int __nacts = (unsigned int) *__acts++;
>  while ( __nacts-- > 0 ) {
>   switch ( *__acts++ ) {
>  case 1:
> #line 193 "BootLoaderStateChart.rl"
>  {
>   }
>  break;
>  case 10:
> #line 363 "BootLoaderStateChart.rl"
>  {
>   }
>  break;
> 
>  
> 
> Digital Mars Compiler command when building the above:
> dmc.exe -c -oDMCDebug\BootLoaderStateChart.obj -D__WXMSW__
> -D__WXDEBUG__ -g -o+none -mn -Ar -Ae -HP299 -w-
> -I"G:\wx287/include" -I"G:\wx287/contrib/include"
> -I"G:\wx287/lib/dmc_lib/mswd" -I" \DM\STLPORT\STLPORT"
> BootLoaderStateChart.cpp
> 
> 
> > 



More information about the ragel-users mailing list