News:

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

Main Menu

Recent posts

#91
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
#92
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
#93
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
#94
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;
}
#95
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;
}
#96
Beginner questions / Re: How to determine compiler ...
Last post by PhilG57 - April 10, 2026, 05:47:28 PM
Hey, many thanks.  The following seems to work great:
#if __POCC_STDC_VERSION__ == 199901
#pragma message("diff.c: Compiler standard is C99.")
#else
#if __POCC_STDC_VERSION__ == 201112
#pragma message("diff.c: Compiler standard is C11.")
#else
#if __POCC_STDC_VERSION__  == 201710
#pragma message("diff.c: Compiler standard is C17.")
#else
#pragma message("diff.c: Compiler standard is unknown.")
#endif
#endif
#endif

Of course, now I'm wondering if there is any way to get this information at run time...
Thanks again.
#97
General discussions / Re: Chinese(simplify) translat...
Last post by John Z - April 10, 2026, 11:56:09 AM
Hi ander_cc,

Quite a lot of work.  But without the string tables  . . . still needs a lot of English understanding. Only if completed would Pelle would consider posting as a language option.

Quote from: ander_cc on April 10, 2026, 11:03:38 AMDue to my limited capability, I have not translated the String Table. The Dialog and Menu have all been translated, with the layout of a small number of Dialog windows adjusted to ensure all text is fully displayed. But some testing is needed.

see attach zip file.
---
Pelles C v14的简体中文翻译,包括全部对话框和菜单,拷贝到安装目录 .\PellesC\Bin\Intl 中即可。

Also please always include English for the posts.  Translated above:

"This is the Simplified Chinese translation for Pelles C v14, covering all dialog boxes and menus. Simply copy it to the installation directory: .\PellesC\Bin\Intl."

John Z

Update: Installed and it is working . . . 👍
#98
General discussions / Chinese(simplify) translation ...
Last post by ander_cc - April 10, 2026, 11:03:38 AM
Due to my limited capability, I have not translated the String Table. The Dialog and Menu have all been translated, with the layout of a small number of Dialog windows adjusted to ensure all text is fully displayed. But some testing is needed.

see attach zip file.
---
Pelles C v14的简体中文翻译,包括全部对话框和菜单,拷贝到安装目录 .\PellesC\Bin\Intl 中即可。
#99
General discussions / Re: I want to translate pelles...
Last post by ander_cc - April 10, 2026, 10:46:10 AM
Quote from: John Z on April 09, 2026, 10:38:00 AMHi ander_cc,

You can find the basic procedure here:
https://web.archive.org/web/20250325220454/https://wiki.pellesc.de/doku.php/translating

Also attached below as a pdf -

But you probably need the version 14 rsrc0009.zip which you can get from  here:
 http://www.pellesc.se


享受
John Z

Thank you very much!
#100
Expert questions / Re: Link error with minhook
Last post by Vortex - April 10, 2026, 09:52:04 AM
Sorry but is it allowed to discuss about API hooking in this forum?