Tricks for shrinking the C output

Started by Quin, April 17, 2025, 04:53:34 PM

Previous topic - Next topic

Quin

Hi,
I was bored and scrolling through the BCX docs today, when $NO_BORLAND and friends caught my eye. I figured I could use them to reduce the size of the C code I'm generating for really no cost. My test program is uphide, my COM-based utility to hide unwanted/troublesome Windows updates.
The only two compilers I have on my system that uphide compiles with are Pelles C (built into BCX), and mSVC. MinGW/Clang both complain about the format of the uac.res file, and I don't use LCCWin. With all these tweaks, I shrank the generated C code by over 2.5 KB. There are some really smart wizards here and I'm curious if you have any tips for making it any smaller?
Just to be clear, there's nothing wrong with the BCX-generated C output. I quite like how readable it is. I'm just bored and curious how small I can manage to make the generated C while still being functional and readable. Have I tried most things I already can?
$No_Borland
$No_GCC_Clang
$No_LCCWin
$Noini
$NO_VKKEYS
#include <wuapi.h>

Dim As Object Session, Searcher, SearchResult, Update, Updates
Dim NumUpdates, I
Comset Session = Com("Microsoft.Update.Session")
Comset Searcher = Session.CreateupdateSearcher()
Searcher.ClientApplicationID = "uphide"
? "Checking for updates..."
Comset SearchResult = Searcher.Search("IsInstalled=0 And IsHidden=0")
NumUpdates = SearchResult.Updates.Count
If NumUpdates = 0 Then
    ? "No updates were found."
    Uncom(SearchResult)
    Uncom(Searcher)
    Uncom(Session)
    End
End If
? "Enter the numbers of the updates you want to hide, seperated by spaces, and press enter. Leave blank to exit."
Dim Index = 1
Comset Updates = SearchResult.Updates
For Each Item In Updates
    Dim Title$
    Title$ = Item.Title
    ? Str$(Index, 1) & ": " & Title$
    Index++
Next
Dim Input$
Input Input$
If Input$ = "" Then
    Uncom(Updates)
    Uncom(SearchResult)
    Uncom(Searcher)
    Uncom(Session)
    End
End If
Dim NumSelections
Dim ToHide[100] As String
NumSelections = Split(ToHide, Input$, " ", 0)
For I = 0 To NumSelections - 1
    Dim CurIndex
    CurIndex = Val(ToHide[I])
    If CurIndex <= 0 Or CurIndex > NumUpdates Then Continue
    Comset Update = Updates.Item(CurIndex - 1)
    If IsObject(Update) Then
        Dim Title$
        Title$ = Update.Title
        Update.Ishidden = True
        ? "Hid " & Title$
        Uncom(Update)
    End If
Next
Pause
Uncom(Updates)
Uncom(SearchResult)
Uncom(Searcher)
Uncom(Session)