News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Recent posts

#31
Beginner questions / Error #2158 Unrecognized type ...
Last post by Jerry - November 11, 2025, 07:07:32 PM
Dear all,

I am working on adding a graphical user interface to one of my curve-fitting codes. The code compiles and runs correctly with several other compilers (CodeBlocks 2025, Visual Studio, Intel OneAPI, and GCC), but Pelles C reports the following error:

Error #2158: Unrecognized type 'ssize_t'


I have already checked previous discussions on this forum and tried the common suggestions, including adding:

#include <sys/types.h>
#define __STDC_WANT_LIB_EXT2__ 1


Unfortunately, the error persists.

Does anyone know how to properly enable or define ssize_t in Pelles C? My understanding is that ssize_t should be available by default, as it is in the other compilers I have tested.

Any suggestions or guidance would be greatly appreciated. Thank you.
#32
Beginner questions / Pomake incompatibility
Last post by italofutura - November 11, 2025, 01:44:55 PM
Hi I try to run this makefile.

Isend here in order to not spam the bug reports (in case I misuse pomake)

Jom 1.1.4 Windows 11 x64

and

Nmake ("c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x64\nmake.exe")

work fine.

Pomake runs the first two dependency lines and crashes with Access Violation.
#33
User contributions / Re: Boot time
Last post by Vortex - November 10, 2025, 08:25:51 PM
Hi Timo,

There is also the GetTickCount function. The documentation states that :

QuoteNtQuerySystemInformation may be altered or unavailable in future versions of Windows.

https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntquerysysteminformation
#34
User contributions / Re: Boot time
Last post by TimoVJL - November 10, 2025, 09:10:14 AM
Quote from: Vortex on November 09, 2025, 08:22:44 PMAnother method to get the boot time is to use the GetTickCount64 API function.
Works only since Vista.

This is quite short.
    NtQuerySystemInformation(SystemTimeOfDayInformation, &stodi, sizeof(stodi), 0);
    // (*(LONGLONG*)&stodi.BootTime) -= (*(LONGLONG*)&stodi.TimeZoneBias);
    stodi.BootTime.QuadPart -= stodi.TimeZoneBias.QuadPart;
    (*(LONGLONG*)&ft) = (*(LONGLONG*)&stodi.BootTime);
    FileTimeToSystemTime(&ft, &st);
#35
User contributions / Re: Boot time
Last post by Vortex - November 09, 2025, 08:22:44 PM
Hi Timo,

Another method to get the boot time is to use the GetTickCount64 API function.
#36
Work in progress / Re: win32-doc md files
Last post by John Z - November 09, 2025, 05:25:49 PM
The completed project is posted over in User Contributions -
https://forum.pellesc.de/index.php?topic=11672.0

Cheers,
John Z
#37
User contributions / Offline GitHub MS Documents
Last post by John Z - November 09, 2025, 05:21:33 PM
Attached is the full release for the access program for the win32-docs.zip downloaded from GitHub:
https://github.com/MicrosoftDocs/win32

This provides a way to use and access documentation (mainly the API Names) from the GitHub documentation effort off-line, and searchable.

The documents can be viewed in the .md format or in a .html format.  Searching is provided in the .md display, and of course intrinsically in the web browser viewing .html.

TimoVJL provided the code/method to search the win32 documentation for API NAMES from which I created a database and the rest of the program.  See readme_v4.txt, for other external source code attributions.

It is possible that the MD_Files_3.db3 could be expanded in the future to include all topics in the win32-docs.zip and that would not require changing the basic program to be immediately useful.  TBD

John Z
#38
Work in progress / Re: ChatGPT examples
Last post by Vortex - November 09, 2025, 10:01:13 AM
Console application to get the boot time :

/* ChatGPT code */

#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <stdio.h>

int main(void)
{
    FILETIME ftNow, ftBootUtc, ftBootLocal;
    ULONGLONG now100ns;
    ULONGLONG uptimeMs;
    ULONGLONG boot100ns;
    SYSTEMTIME st;

    /* current system time as FILETIME (UTC, 100-ns intervals since 1601) */
    GetSystemTimeAsFileTime(&ftNow);
    now100ns = ((ULONGLONG)ftNow.dwHighDateTime << 32) | ftNow.dwLowDateTime;

    /* milliseconds since system start */
    uptimeMs = GetTickCount64(); /* Vista+; returns milliseconds since boot */

    /* convert uptime to 100-ns units and subtract */
    boot100ns = now100ns - (uptimeMs * 10000ULL);

    /* convert back to FILETIME structure */
    ftBootUtc.dwLowDateTime  = (DWORD)(boot100ns & 0xFFFFFFFF);
    ftBootUtc.dwHighDateTime = (DWORD)(boot100ns >> 32);

    /* show UTC boot time */
    if (FileTimeToSystemTime(&ftBootUtc, &st)) {
        printf("Boot time (UTC)  : %04u-%02u-%02u %02u:%02u:%02u\n",
               st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
    }

    /* convert to local time and show */
    if (FileTimeToLocalFileTime(&ftBootUtc, &ftBootLocal) &&
        FileTimeToSystemTime(&ftBootLocal, &st)) {
        printf("Boot time (local): %04u-%02u-%02u %02u:%02u:%02u\n",
               st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
    }

    return 0;
}
#39
User contributions / Re: Boot time
Last post by Vortex - November 08, 2025, 10:10:06 PM
Hi Timo,

Keep up the nice work.
#40
User contributions / Boot time
Last post by TimoVJL - November 08, 2025, 03:01:42 PM
Inspirate from
http://masm32.com/board/index.php?msg=140972
I might fix this later.

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#define NTSTATUS  LONG

typedef struct _SYSTEM_TIMEOFDAY_INFORMATION
{
    LARGE_INTEGER BootTime;                     // Number of 100-nanosecond intervals since the system was started.
    LARGE_INTEGER CurrentTime;                  // The current system date and time.
    LARGE_INTEGER TimeZoneBias;                 // Number of 100-nanosecond intervals between local time and Coordinated Universal Time (UTC).
    ULONG TimeZoneId;                           // The current system time zone identifier.
    ULONG Reserved;                             // Reserved
    ULONGLONG BootTimeBias;                     // Number of 100-nanosecond intervals between the boot time and Coordinated Universal Time (UTC).
    ULONGLONG SleepTimeBias;                    // Number of 100-nanosecond intervals between the sleep time and Coordinated Universal Time (UTC).
} SYSTEM_TIMEOFDAY_INFORMATION, *PSYSTEM_TIMEOFDAY_INFORMATION;

#define SystemTimeOfDayInformation 3
// enum SYSTEM_INFORMATION_CLASS

//NTSTATUS WINAPI NtQuerySystemInformation(int SystemInformationClass,
//    PVOID SystemInformation, ULONG SystemInformationLength, PULONG ReturnLength);

typedef int (WINAPI NTQUERYSYSTEMINFORMATION)(int SystemInformationClass,
    PVOID SystemInformation, ULONG SystemInformationLength, PULONG ReturnLength);
typedef NTQUERYSYSTEMINFORMATION *LNTQUERYSYSTEMINFORMATION;
// FILETIME SYSTEMTIME
void __cdecl WinMainCRTStartup(void)
{
    HANDLE hLib;
    static LNTQUERYSYSTEMINFORMATION NtQuerySystemInformation;
    SYSTEM_TIMEOFDAY_INFORMATION stodi;
    FILETIME ft;
    SYSTEMTIME st;
    char szBuf[50];
    hLib = LoadLibrary("ntdll.dll");
    NtQuerySystemInformation = (LNTQUERYSYSTEMINFORMATION)GetProcAddress(hLib, "NtQuerySystemInformation");
    NtQuerySystemInformation(SystemTimeOfDayInformation, &stodi, sizeof(stodi), 0);
    (*(LONGLONG*)&stodi.BootTime) -= (*(LONGLONG*)&stodi.TimeZoneBias);
    ft.dwLowDateTime = ((LARGE_INTEGER*)&stodi.BootTime)->LowPart;
    ft.dwHighDateTime = ((LARGE_INTEGER*)&stodi.BootTime)->HighPart;
    FileTimeToSystemTime(&ft, &st);
    wsprintf(szBuf, "Date: %04d-%02d-%02d\nTime: %02d:%02d:%02d", st.wYear, st.wMonth, st.wDay,
        st.wHour, st.wMinute, st.wSecond);
    MessageBox(0, szBuf, "Boot time", MB_OK);
    ExitProcess(0);
}