FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour What's wrong with this C code?
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
What's wrong with this C code?
Posted: Mon Feb 14, 2011 11:47 AM
Hi,

compiling with xCC:
test.prg(6502): error: Operands of = have illegal types 'char *' and 'const char *'.



Complete code:
Code (fw): Select all Collapse
#pragma BEGINDUMP
#include <Windows.h>
#include <mapiwin.h>
#include <ClipApi.h>

HB_FUNC( FILETIMES ) // params cFileName, nTime --> { nYear, nMonth, nDay, nHour, nMin, nSec }
{
   LPSTR cFileName = hb_parc( 1 );
   int nTime       = ( ISNUM( 2 ) ? hb_parni( 2 ) :  1 ) ; // defaults to 1

   FILETIME ftCreate, ftAccess, ftWrite ;
   SYSTEMTIME stTime ;
   //BOOL bRet ;
   HANDLE hFile = CreateFile( cFileName, GENERIC_READ, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ) ;

   if( ! hFile )
      return ;

   GetFileTime( (HANDLE) hFile, &ftCreate, &ftAccess, &ftWrite ) ;

   switch( nTime )
   {
      case 1 : // last update
         FileTimeToSystemTime( &ftWrite, &stTime ) ;
         break ;
      case 2 : // last access
         FileTimeToSystemTime( &ftAccess, &stTime ) ;
         break ;
      case 3 : // creation
         FileTimeToSystemTime( &ftCreate, &stTime ) ;
         break ;
      default : // last update
         FileTimeToSystemTime( &ftWrite, &stTime ) ;
         break ;
   }

   SystemTimeToTzSpecificLocalTime( NULL, &stTime, &stTime ) ;
   CloseHandle( hFile ) ;
   hb_reta( 6 ) ;
   hb_storni( stTime.wYear,   -1, 1 ) ;
   hb_storni( stTime.wMonth,  -1, 2 ) ;
   hb_storni( stTime.wDay,    -1, 3 ) ;
   hb_storni( stTime.wHour,   -1, 4 ) ;
   hb_storni( stTime.wMinute, -1, 5 ) ;
   hb_storni( stTime.wSecond, -1, 6 ) ;
}
#pragma ENDDUMP


What's wrong?
Windows 11 Pro 22H2 22621.1848

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Harbour 3.2.0dev (r2008190002)

FWH 23.10 x86
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: What's wrong with this C code?
Posted: Mon Feb 14, 2011 01:05 PM
Hello

Code (fw): Select all Collapse
LPSTR cFileName = ( LPSTR ) hb_parc( 1 );
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: What's wrong with this C code?
Posted: Mon Feb 14, 2011 01:30 PM

Daniel,

it works, many thanks :)

Windows 11 Pro 22H2 22621.1848

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Harbour 3.2.0dev (r2008190002)

FWH 23.10 x86

Continue the discussion