News:

Download Pelles C here: http://www.pellesc.se

Main Menu

Recent posts

#22
General discussion / Re: about complex.h
Last post by crun - April 12, 2026, 06:50:29 AM
> As the complex.h was removed,

I am trying to compile an old project from 2016-2018, which used complex.h, and the project file tags as C99

Can anyone suggest what version I should start with appropriate to those years, and before complex.h was removed?

Alternatively, perhaps it was never in the PellesC installer, and the OG programmer got if from somewhere else?
#23
Assembly discussions / Re: Trackbar control
Last post by Vortex - April 11, 2026, 10:28:28 PM
Modified 64-bit version to reflect the X64 RIP-relative addressing, expr WRT rip
#24
Expert questions / Re: Link error with minhook
Last post by Pelle - April 11, 2026, 03:39:53 PM
Quote from: Vortex on April 10, 2026, 09:52:04 AMSorry but is it allowed to discuss about API hooking in this forum?
Like many other things, this can be used for both good and bad.
It depends on the context. So far I see nothing out of line here...
#25
Expert questions / Re: Link error with minhook
Last post by Pelle - April 11, 2026, 03:36:43 PM
Quote from: unwake on April 10, 2026, 04:09:53 AMhttps://github.com/TsudaKageyu/minhook/releases/tag/v1.3.4
Minhook has dynamic and static lib, link with dynamic lib is ok, but link with static lib "libMinHook.x64.lib", say error:
POLINK: fatal error: Unsupported anonymous format in object 'x64\Release\libMinHook\hook.obj'.
can you fix it ?
I can't find any documentation about this format (I'm guessing this is a some semi-new Microsoft crap, and with their documentation department being years behind everyone else, maybe not surprising). I will keep looking, but with no proper documentation I'm not sure what I can do...

EDIT: after some testing, this looks like MSVC link-time code generation. This library can only work with Microsoft tools ...

#26
Beginner questions / Re: How to determine compiler ...
Last post by John Z - April 11, 2026, 01:26:19 PM
Might want to update and add:


        case 202311:
            printf ("diff.c: Compiler standard is C23 (%lu).\n", C_version);
            break;

to be complete -

John Z
#27
Add-ins / Re: Named Bookmarks
Last post by John Z - April 11, 2026, 01:01:49 PM
New version for Pelles C V14.
No major changes but one new warning:
warning #2808: Multiple unsequenced references to 'p_tmp'.

from:
p_tmp = wcsstr(++p_tmp,L":");// worked but ....

to:
p_tmp++;
p_tmp = wcsstr(p_tmp,L":");// no warning now....

so decided to make minor update -

Entire project zip attached.
John Z
#28
General discussions / Re: Chinese(simplify) translat...
Last post by John Z - April 11, 2026, 11:10:43 AM
Hi ander_cc,

For the string tables you might consider using AI.  Here is an example input and output from Gemini

Input to AI
   
  Translate only the quoted text into Chinese Simplified -  
    IDS_BADSCREENRESOLUTION, "The effective screen resolution must be at least %dx%d.\r\nIt is recommended that you either increase your screen resolution setting or reduce your DPI scaling setting. Continue\?"
    IDS_BADCOMCTLVERSION, "The system file COMCTL32.DLL is missing or too old.\r\nPelles C IDE require version %ls or higher."
    IDS_BADVERSION, "Bad version on \'%ls\'."
    IDS_OUTOFMEMORY, "Out of memory."
    IDS_MEMORYERROR, "Memory error! Try to save your files - but exit as soon as possible!"
    IDS_COMMDLGERROR, "Error in Windows Common Dialog (this shouldn\'t have happened!). The error code is 0x%lx."
    IDS_THREADERROR, "Unable to create new process or thread."
    IDS_DEBUGGERERROR, "Internal debugger error!\r\n\r\nException code: %08X\r\nException address: %P"
    IDS_EXECERROR, "Unable to execute \'%ls\'."
    IDS_PIPEERROR, "Unable to create a new pipe."
    IDS_BADNUMBER, "Invalid numeric value."
    IDS_BACKUPERROR, "Error initializing backup copy for file \'%ls\'."
    IDS_CHANGEDIRERROR, "Unable to change to folder \'%ls\'."
    IDS_CREATEDIRERROR, "Unable to create folder \'%ls\'."
 
Output from AI 
 
  IDS_BADSCREENRESOLUTION, "有效屏幕分辨率必须至少为 %dx%d。\r\n建议您调高屏幕分辨率设置,或调低 DPI 缩放设置。是否继续?"
  IDS_BADCOMCTLVERSION, "系统文件 COMCTL32.DLL 丢失或版本过旧。\r\nPelles C IDE 需要 %ls 或更高版本。"
  IDS_BADVERSION, "\'%ls\' 版本错误。"
  IDS_OUTOFMEMORY, "内存不足。"
  IDS_MEMORYERROR, "内存错误!请尝试保存文件 — 但请尽快退出程序!"
  IDS_COMMDLGERROR, "Windows 通用对话框出错(不应出现此错误!)。错误代码为 0x%lx。"
  IDS_THREADERROR, "无法创建新进程或线程。"
  IDS_DEBUGGERERROR, "调试器内部错误!\r\n\r\n异常代码:%08X\r\n异常地址:%P"
  IDS_EXECERROR, "无法执行 \'%ls\'。"
  IDS_PIPEERROR, "无法创建新管道。"
  IDS_BADNUMBER, "无效的数值。"
  IDS_BACKUPERROR, "初始化文件 \'%ls\' 的备份副本时出错。"
  IDS_CHANGEDIRERROR, "无法切换至文件夹 \'%ls\'。"
  IDS_CREATEDIRERROR, "无法创建文件夹 \'%ls\'。"


You will need to be the judge of the accuracy and perhaps fix a few things here and there but this technique should be able to get you to the finish line.

John Z
#29
Beginner questions / Re: How to determine compiler ...
Last post by Michele - April 11, 2026, 12:35:57 AM
Quote from: PhilG57 on April 10, 2026, 05:47:28 PMOf course, now I'm wondering if there is any way to get this information at run time...
Thanks again.
Try this:
#include <stdio.h>
#include <stdlib.h>

/*
 * Get the C standard independently from MS compatible
 * mode setting
 */
#ifdef __STDC_VERSION__
#define C_VERSION __STDC_VERSION__
#else
#define C_VERSION __POCC_STDC_VERSION__
#endif

const unsigned long C_version = C_VERSION;

int main(int argc, char *argv[])
{
    switch(C_version)
    {
        case 199901:
            printf ("diff.c: Compiler standard is C99 (%lu).\n", C_version);
            break;

        case 201112:
            printf ("diff.c: Compiler standard is C11 (%lu).\n", C_version);
            break;

        case 201710:
            printf ("diff.c: Compiler standard is C17 (%lu).\n", C_version);
            break;

        default:
            printf ("diff.c: Compiler standard is unknown (%lu).\n", C_version);
            break;
    }

    return 0;
}
#30
Work in progress / Re: ChatGPT examples
Last post by Vortex - April 10, 2026, 10:26:35 PM
QuickXorHash calculator :

// Code by Google Gemini

#include <stdio.h>
#include <stdint.h>
#include <string.h>

// const char b64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

// Some tools (like rclone in certain modes) use Base64Url, which is a variant designed to be safe for filenames and URLs.
// In that variant, + is replaced with - and / is replaced with _.

// Rclone compatibility

const char b64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";

typedef struct {
    uint8_t buffer[20];
    uint64_t length;
    int shift;
} QuickXorHashContext;

void qxh_init(QuickXorHashContext *ctx) {
    memset(ctx, 0, sizeof(QuickXorHashContext));
}

void qxh_update(QuickXorHashContext *ctx, const uint8_t *payload, size_t len) {
    for (size_t i = 0; i < len; i++) {
        int byte_pos = ctx->shift / 8;
        int bit_pos = ctx->shift % 8;
        uint8_t v = payload[i];

        // XOR with explicit cast to uint8_t to suppress Pelles C warnings
        ctx->buffer[byte_pos] ^= (uint8_t)(v << bit_pos);
       
        // Handle overflow into the next byte (circularly)
        if (bit_pos > 0) {
            int next_byte = (byte_pos + 1) % 20;
            ctx->buffer[next_byte] ^= (uint8_t)(v >> (8 - bit_pos));
        }

        ctx->shift = (ctx->shift + 11) % 160;
    }
    ctx->length += len;
}

void qxh_finalize(QuickXorHashContext *ctx, uint8_t *out) {
    memcpy(out, ctx->buffer, 20);

    // XOR the 64-bit length into the last 8 bytes (Little Endian)
    for (int i = 0; i < 8; i++) {
        out[12 + i] ^= (uint8_t)((ctx->length >> (8 * i)) & 0xFF);
    }
}

void base64_encode(const uint8_t *in, char *out) {
    int i, j = 0;
    for (i = 0; i < 18; i += 3) {
        out[j++] = b64_table[in[i] >> 2];
        out[j++] = b64_table[((in[i] & 0x03) << 4) | (in[i+1] >> 4)];
        out[j++] = b64_table[((in[i+1] & 0x0f) << 2) | (in[i+2] >> 6)];
        out[j++] = b64_table[in[i+2] & 0x3f];
    }
    out[j++] = b64_table[in[18] >> 2];
    out[j++] = b64_table[((in[18] & 0x03) << 4) | (in[19] >> 4)];
    out[j++] = b64_table[(in[19] & 0x0f) << 2];
    out[j++] = '=';
    out[j] = '\0';
}

int main(int argc, char *argv[]) {
    if (argc < 2) {
        printf("Usage: qxh <file>\n");
        return 1;
    }
   
    FILE *f = fopen(argv[1], "rb");
    if (!f) {
        perror("Error opening file");
        return 1;
    }

    QuickXorHashContext ctx;
    qxh_init(&ctx);
   
    uint8_t buf[16384];
    size_t n;
    while ((n = fread(buf, 1, sizeof(buf), f)) > 0) {
        qxh_update(&ctx, buf, n);
    }
    fclose(f);

    uint8_t hash[20];
    char b64[29];
    qxh_finalize(&ctx, hash);
    base64_encode(hash, b64);
   
    printf("%s\n", b64);
    return 0;
}