News:

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

Main Menu

Recent posts

#71
Bug reports / Re: array struct assignments
Last post by PaoloC13 - May 25, 2026, 12:00:54 AM
Regret. I have to go back to the beginners forum.
#72
Bug reports / Re: array struct assignments
Last post by Michele - May 24, 2026, 05:44:45 PM
You should never return an automatic variable.
's' is allocated on the stack, and is overwritten by other data when function exits.
You can declare it 'static' as suggested or define it in the caller and pass it.
#73
Bug reports / Re: array struct assignments
Last post by TimoVJL - May 24, 2026, 05:08:29 PM
Think using static keyword
Mat4 broken(void) {
    static Mat4 s;
    memset(&s, 0, sizeof(s));   // set the block
    s.m[0] = 1.0f;              // explicit
    return s;
}
#74
Bug reports / array struct assignments
Last post by PaoloC13 - May 24, 2026, 04:24:16 PM
When I copy a returned struct { T arr[N]; } into the caller, it skips array elements whose value came from memset or ={0}. Only elements with explicit individual assignments are written.

typedef struct { float m[16]; } Mat4;

    Mat4 broken(void) {
        Mat4 s;
        memset(&s, 0, sizeof(s));   // set the block
        s.m[0] = 1.0f;              // explicit
        return s;
    }

    // Caller:
    Mat4 result;
    memset(&result, 0xCC, sizeof(result));   // fill with known garbage
    result = broken();

  /* Expected per C standard: result.m[1] == 0.0f           */
  /* Observed:                result.m[1] == -1.07374e+08   */
  /*   (the 0xCC garbage — the copy never wrote that slot)  */

Test: pre-fill the destination with a recognisable non-zero sentinel (0xCC bytes works well) before the call.
If any zero-expected field shows the sentinel value after the call, the copy skipped it.

My fix: explicitly assign every element of the array.
Is this a bug or a normal behaviour?
#75
Tips & tricks / Re: Implementation of CommandL...
Last post by TimoVJL - May 22, 2026, 01:52:06 PM
Nice to have, if want to have a common ANSI / UNICODE project.
#76
Tips & tricks / Implementation of CommandLineT...
Last post by Vortex - May 21, 2026, 10:13:13 PM
QuoteImplementation of CommandLineToArgv for Win32
(ANSI and alternative Unicode versions)

http://alter.org.ua/docs/win/args/

QuoteCommandLineToArgvA

Collection of functions implement CommandLineToArgvA, the ANSI version of CommandLineToArgvW in windows API

https://github.com/futurist/CommandLineToArgvA
#77
Beginner questions / Re: same code pelles c and gcc...
Last post by John Z - May 21, 2026, 03:13:02 AM
Quote from: ander_cc on March 15, 2026, 11:30:22 AM#include <stdio.h>
#include <stdbit.h>
int main() {
    unsigned short a1 = 4;
    unsigned int a2 = 4;

    printf("a1 one:%u  a1 zero:%u\n", stdc_first_leading_one(a1), stdc_first_leading_zero(a1));
    printf("a2 one:%u  a2 zero:%u\n", stdc_first_leading_one(a2), stdc_first_leading_zero(a2));
   
    return 0;
}
gcc 11.4 -std=c23
a1 one:14  a1 zero:1
a2 one:30  a2 zero:1
-----
pelles c 13.01
a1 one:3  a1 zero:16
a2 one:3  a2 zero:32
-----
WHY? and which is right?

Confirming Pelles C 14.1 now reports
a1 one:14  a1 zero:1
a2 one:30  a2 zero:1


John Z
#78
Assembly discussions / Re: Combining object files
Last post by Vortex - May 16, 2026, 10:07:19 PM
Hi Timo,

Thanks, it's all about practical programming. Right tool for the right job.
#79
Add-ins / Re: SelectLine
Last post by John Z - May 15, 2026, 05:53:57 PM
Well I guess idle for the moment - so here is a better version of SelectLine Add-in.  Version 2 will do both partial line selects and whole line select (when cursor is anywhere in the line).

Operation mode is user configured using Main Menu Tools, Options, Add-ins.
Select the add-in 'Click to select line', then click the Options button on the right.  Answer the dialog question, this will configure the select line mode.  Change anytime using the same procedure.  The mode is retained even when Pelles IDE is closed and reopened. 


Project sources attached, easy to build or use existing SelectLine.dll


John Z
#80
Assembly discussions / Re: Combining object files
Last post by TimoVJL - May 15, 2026, 11:19:54 AM
Hi Erol,

Basically a nice idea to avoid using msvcrt.dll in some projects with poasm.