News:

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

Main Menu

Recent posts

#81
Expert questions / Re: Re: Using a structure as r...
Last post by TimoVJL - May 31, 2025, 11:47:10 AM
Not sure what you mean.
This example shows {} calculate_statistics in project panel.
typedef struct {
    int count;
    double min;
    double max;
    double mean;
    double median;
    double mode;
    double std_dev;
    double coeff_variation;
    double skewness;
    double kurtosis;
} Statistics;

Statistics calculate_statistics(void* gsData, int nRows, int vCol)
{
}
#82
Expert questions / Re: Using a structure as retur...
Last post by pkparchure - May 31, 2025, 09:32:07 AM
Dear Forum
I am facing a peculiar problem with Pelles C IDE. I have tried using a structure as return value for function. For example my function for computing the Statistcs is
// Function to calculate all statistics
Statistics calculate_statistics(DataStruct gsData, int nRows, int vCol) where Statistics is a structure:
typedef struct {
    int count;
    double min;
    double max;
    double mean;
    double median;
    double mode;
    double std_dev;
    double coeff_variation;
    double skewness;
    double kurtosis;
} Statistics;
The program works very well but the problem is that this function is not shown in side panel.
In fact any function with return variable not given as void, int, float, double, etc, is not shown in side panel.

I have put the screenshot of IDE. I am using Version 13 now. Is it a bug in IDE or I am missing something in IDE

#83
Bug reports / Re: IDE issue
Last post by John Z - May 30, 2025, 11:23:48 PM
Thanks Pelle, I'll watch closely from now on. It is not frequent. If I ever can intentionally make it happen I'll post again.

Thanks Robert - I do prefer case insensitive though.

John Z
#84
Bug reports / Re: IDE issue
Last post by Pelle - May 30, 2025, 09:17:25 PM
John Z,

What I'm trying to say is that I never "normalize" a filename, never turn "TEST.C" into "test.c" or something like that. I use the exact spelling returned from functions like FindFirstFile*() / FindNextFile*(). The fact that you have two different spellings means your directory at one point must have contained "DBSearch.c" and at another point must have contained "dbsearch.c". This is a fact (and that Windows can match "TeSt.C" with the name "test.c" stored in the directory is irrelevant).

It seems most likely that it was a user action that renamed "dbsearch.c" into "DBSearch.c", or vice versa. But you are closer to this possible action...
#85
Bug reports / Re: IDE issue
Last post by Robert - May 30, 2025, 09:03:31 PM
#86
Bug reports / Re: IDE issue
Last post by John Z - May 30, 2025, 07:57:20 PM
Thanks Pelle,

It's an idea. I'm sure at some point I've renamed a file but not to just change case I think.  Also Windows does not distinguish case in the file name, I believe. 

I'll run a few test along this line of thinking though.

John Z
#87
Bug reports / Re: IDE issue
Last post by Pelle - May 30, 2025, 04:51:06 PM
AFAIK, all tools will pick up the exact spelling of a filename. If the .tag database contains "DBSearch.c" and "dbsearch.c", both spellings must have been present on your disk at some point.

Can you remember renaming this file, and if it was done from the IDE or from Windows (Explorer / Command line / whatever)?
#88
Work in progress / Re: ChatGPT examples
Last post by Quin - May 29, 2025, 11:27:42 PM
Thanks Vortex! As the author of uphide, I can appreciate this example for sure.
#89
Work in progress / Re: ChatGPT examples
Last post by Vortex - May 29, 2025, 08:37:58 PM
Windows update example :

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <wuapi.h>
#include <oleauto.h>
#include <stdio.h>
#include <conio.h>
#include <wchar.h>

#pragma comment(lib, "ole32.lib")
#pragma comment(lib, "oleaut32.lib")

// Function to initialize COM and create Update Session
HRESULT InitializeUpdateSession(IUpdateSession** ppSession)
{
    HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
    if (FAILED(hr))
    {
        printf("CoInitializeEx failed: 0x%08X\n", hr);
        return hr;
    }

    hr = CoCreateInstance(&CLSID_UpdateSession, NULL, CLSCTX_INPROC_SERVER,
                         &IID_IUpdateSession, (LPVOID*)ppSession);
    if (FAILED(hr))
    {
        printf("CoCreateInstance failed: 0x%08X\n", hr);
        CoUninitialize();
    }

    return hr;
}

// Function to search for updates
HRESULT SearchForUpdates(IUpdateSession* pSession, IUpdateSearcher** ppSearcher,
                         IUpdateCollection** ppUpdates)
{
    HRESULT hr = pSession->lpVtbl->CreateUpdateSearcher(pSession, ppSearcher);
    if (FAILED(hr))
    {
        printf("CreateUpdateSearcher failed: 0x%08X\n", hr);
        return hr;
    }

    // Search for all updates
    ISearchResult* pResult = NULL;
    hr = (*ppSearcher)->lpVtbl->Search(*ppSearcher, L"IsInstalled=0", &pResult);
    if (FAILED(hr))
    {
        printf("Search failed: 0x%08X\n", hr);
        return hr;
    }

    // Get the updates that were found
    hr = pResult->lpVtbl->get_Updates(pResult, ppUpdates);
    if (FAILED(hr))
    {
        printf("get_Updates failed: 0x%08X\n", hr);
        pResult->lpVtbl->Release(pResult);
        return hr;
    }

    pResult->lpVtbl->Release(pResult);
    return S_OK;
}

// Function to display available updates
HRESULT DisplayUpdates(IUpdateCollection* pUpdates)
{
    LONG count = 0;
    HRESULT hr = pUpdates->lpVtbl->get_Count(pUpdates, &count);
    if (FAILED(hr))
    {
        printf("get_Count failed: 0x%08X\n", hr);
        return hr;
    }

    printf("Found %d available updates:\n\n", count);

    for (LONG i = 0; i < count; i++)
    {
        IUpdate* pUpdate = NULL;
        hr = pUpdates->lpVtbl->get_Item(pUpdates, i, &pUpdate);
        if (FAILED(hr))
        {
            printf("get_Item failed for update %d: 0x%08X\n", i, hr);
            continue;
        }

        BSTR title = NULL;
        hr = pUpdate->lpVtbl->get_Title(pUpdate, &title);
        if (SUCCEEDED(hr))
        {
            printf("%d. %ls\n", i + 1, title);
            SysFreeString(title);
        }

        pUpdate->lpVtbl->Release(pUpdate);
    }

    return S_OK;
}

// Function to download updates
HRESULT DownloadUpdates(IUpdateSession* pSession, IUpdateCollection* pUpdates)
{
    IUpdateDownloader* pDownloader = NULL;
    HRESULT hr = pSession->lpVtbl->CreateUpdateDownloader(pSession, &pDownloader);
    if (FAILED(hr))
    {
        printf("CreateUpdateDownloader failed: 0x%08X\n", hr);
        return hr;
    }

    hr = pDownloader->lpVtbl->put_Updates(pDownloader, pUpdates);
    if (FAILED(hr))
    {
        printf("put_Updates failed: 0x%08X\n", hr);
        pDownloader->lpVtbl->Release(pDownloader);
        return hr;
    }

    printf("\nDownloading updates...\n");
    IDownloadResult* pResult = NULL;
    hr = pDownloader->lpVtbl->Download(pDownloader, &pResult);
    if (FAILED(hr))
    {
        printf("Download failed: 0x%08X\n", hr);
        pDownloader->lpVtbl->Release(pDownloader);
        return hr;
    }

    pDownloader->lpVtbl->Release(pDownloader);
    pResult->lpVtbl->Release(pResult);
    printf("Download completed.\n");
    return S_OK;
}

// Function to install updates
HRESULT InstallUpdates(IUpdateSession* pSession, IUpdateCollection* pUpdates)
{
    IUpdateInstaller* pInstaller = NULL;
    HRESULT hr = pSession->lpVtbl->CreateUpdateInstaller(pSession, &pInstaller);
    if (FAILED(hr))
    {
        printf("CreateUpdateInstaller failed: 0x%08X\n", hr);
        return hr;
    }

    hr = pInstaller->lpVtbl->put_Updates(pInstaller, pUpdates);
    if (FAILED(hr))
    {
        printf("put_Updates failed: 0x%08X\n", hr);
        pInstaller->lpVtbl->Release(pInstaller);
        return hr;
    }

    printf("\nInstalling updates...\n");
    IInstallationResult* pResult = NULL;
    hr = pInstaller->lpVtbl->Install(pInstaller, &pResult);
    if (FAILED(hr))
    {
        printf("Install failed: 0x%08X\n", hr);
        pInstaller->lpVtbl->Release(pInstaller);
        return hr;
    }

    short int rebootRequired = 0;
    pResult->lpVtbl->get_RebootRequired(pResult, &rebootRequired);
    if (rebootRequired)
    {
        printf("\nA system reboot is required to complete the installation.\n");
    }

    pInstaller->lpVtbl->Release(pInstaller);
    pResult->lpVtbl->Release(pResult);
    printf("Installation completed.\n");
    return S_OK;
}

int main(void)
{
    printf("Windows Update Installer\n");
    printf("=======================\n\n");

    IUpdateSession* pSession = NULL;
    IUpdateSearcher* pSearcher = NULL;
    IUpdateCollection* pUpdates = NULL;

    // Initialize and search for updates
    HRESULT hr = InitializeUpdateSession(&pSession);
    if (SUCCEEDED(hr))
    {
        hr = SearchForUpdates(pSession, &pSearcher, &pUpdates);
    }

    // Display updates if found
    if (SUCCEEDED(hr))
    {
        hr = DisplayUpdates(pUpdates);
    }

    // Ask user if they want to proceed
    if (SUCCEEDED(hr) && pUpdates)
    {
        LONG count = 0;
        pUpdates->lpVtbl->get_Count(pUpdates, &count);
       
        if (count > 0)
        {
                // Download and install updates
                hr = DownloadUpdates(pSession, pUpdates);
                if (SUCCEEDED(hr))
                {
                    hr = InstallUpdates(pSession, pUpdates);
                }
        }
        else
        {
            printf("No updates available.\n");
        }
    }

    // Cleanup
    if (pUpdates) pUpdates->lpVtbl->Release(pUpdates);
    if (pSearcher) pSearcher->lpVtbl->Release(pSearcher);
    if (pSession) pSession->lpVtbl->Release(pSession);
    CoUninitialize();

    if (FAILED(hr))
    {
        printf("\nAn error occurred: 0x%08X\n", hr);
        return 1;
    }

    return 0;
}
#90
Bug reports / IDE issue
Last post by John Z - May 29, 2025, 05:29:39 PM
Pelle said
"If the problem relates to the Integrated Environment (IDE), try to provide step-by-step instructions how to reproduce the problem. I can't guess what you did. If you don't know - I don't know. A screenshot will almost always help, but is usually not enough by itself..."

So here is an issue I can't create at will,  I do not know how it happens or what I do to cause it.  It is easily fixable by deleting the .tag file.  So I'm not saying bug  ;D

The source file panel doubles the file entries shown in the first image.  The second image shows that the filename has not changed yet below that it shows when I select the source file a window to resolve the 'issue'.

I attached the .tag file which contains the doubled names with case change.

I never posted before because I can't reproduce at will, a primary necessity for a bug report.  Has been something weird that I do, I guess, as far back as at least V11 or further back.

SO - Just in case anyone else has observed this and are able to reproduce 'at will'.

John Z