This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

<time.h> bug???


 i got error(warning) messages in compiling the following source.

from cygnus gnu-win32 b19.1

BASH.EXE-2.01$ gcc wingui.c -o wingui.exe -lgdi32 -luser32
wingui.c: In function `TimeCal':
wingui.c:67: warning: assignment makes pointer from integer without a
cast
wingui.c:69: warning: assignment makes pointer from integer without a
cast
BASH.EXE-2.01$
and from the lcc compiler, similar errors! occured.

<complete source is attached>...

char* TimeCal( void )
{
 int i;
 static struct tm *newtime;
 static time_t t;
 static char cTime[50];
 static char *Total;
 char *str = " ";

 t = time( NULL );
 newtime = localtime( &t );
 strcpy( cTime, asctime(newtime) );
 cTime[strlen(cTime) - 1] = '\0';
 Total = strtok(cTime, str);          <-- #67 if (char*) is inserted, it

is compiled sucessfully.
 for ( i = 0; i < 3; i++ )
  Total = strtok(NULL, str);          <-- #69 if (char*) is inserted, it

is compiled sucessfully.
 return Total;
}

but i succeed to compile it for a console program with djgpp &
cygnus-win32... and my friend report me that VC++5.0 handles it
correctly.
what makes this difference??? or is it a compiler error?

thank you in advance~
 
 
 
 

#include <windows.h>
#include <stdio.h>
#include <time.h>
 

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain
(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArg, int
nCmdShow)
{

        HWND hWnd;
        MSG msg;
        WNDCLASS WndClass;
        char szAppName[] ="This program is to create window";

        WndClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
        WndClass.lpfnWndProc = WndProc;
        WndClass.cbClsExtra = 0;
        WndClass.cbWndExtra = 0;
        WndClass.hInstance = hInstance;
        WndClass.hIcon = LoadIcon(NULL, IDI_HAND);
        WndClass.hCursor = LoadCursor(NULL, IDC_IBEAM);
        WndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
        WndClass.lpszMenuName = NULL;
        WndClass.lpszClassName = szAppName;
        if(!RegisterClass(&WndClass)) return FALSE;

        hWnd = CreateWindow(
                                szAppName,
                                szAppName,
                                WS_OVERLAPPEDWINDOW,
                                CW_USEDEFAULT,
                                CW_USEDEFAULT,
                                CW_USEDEFAULT,
                                CW_USEDEFAULT,
                                NULL,
                                NULL,
                                hInstance,
                                NULL
                        );

        ShowWindow(hWnd, nCmdShow);
        UpdateWindow(hWnd);

        while(GetMessage(&msg, NULL, 0, 0))
        {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
        }
        return msg.wParam;
}

char* TimeCal( void )
{
        int i;
        static struct tm *newtime;
        static time_t t;
        static char cTime[50];
        static char *Total;
        char *str = " ";

        t = time( NULL );
        newtime = localtime( &t );
        strcpy( cTime, asctime(newtime) );
        cTime[strlen(cTime) - 1] = '\0';
        Total = (char*)strtok(cTime, str);
        for ( i = 0; i < 3; i++ )
                Total = (char*)strtok(NULL, str);
    return Total;
}

LRESULT CALLBACK WndProc( HWND hWnd, UINT mesg, WPARAM wParam, LPARAM
lParam )
{
        HDC hDC;

        static char szTimer[80];

        switch( mesg )
    {
                case WM_CREATE :
                        SetTimer( hWnd, 100, 1000, NULL );
                        return FALSE;

                case WM_TIMER :
                        switch( LOWORD(wParam))
                        {
                                case 100 :

                                        hDC = GetDC( hWnd );
                                        TextOut( hDC, 100, 100, szTimer,

                                                        sprintf(szTimer,
"Current Time : %s", TimeCal())
                                        );
                                        ReleaseDC( hWnd, hDC );
                                        break;
                        }
                        return FALSE;
 

        case WM_DESTROY :

            PostQuitMessage(0);
            return FALSE;
    }
    return DefWindowProc(hWnd, mesg, wParam, lParam);
}

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]