home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 241,460 of 243,242   
   bart to Keith Thompson   
   Re: New and improved version of cdecl   
   24 Oct 25 14:27:40   
   
   From: bc@freeuk.com   
      
   On 24/10/2025 03:00, Keith Thompson wrote:   
   > bart  writes:   
   >> On 24/10/2025 00:04, Keith Thompson wrote:   
   >>> bart  writes:   
   > [...]   
   >   
   > I note that you've ignored the vast majority of my previous article.   
      
   I've noted it, but chose not to reply. You have a point of view and   
   attitude which I don't share.   
      
   Mainly that you don't care how complicated a program for even a simple   
   task is, and how laborious and OS-dependent its build process is, so   
   long as it (eventually) works.   
      
   That it favours your own OS, leaving users of other to have to jump   
   through extra hoops, doesn't appear to bother you.   
      
   The actual task in this case must be one of the most OS-agnostic tasks   
   there is: read some text, write some text.   
      
   (The ccu.c file I posted was configured for Linux, but an OS-agnostic   
   version is possible too. The file mcc.c on the same site, will build on   
   both Windows and Linux, but it lacks the '$showmode' feature.)   
      
   >   
   >>>> Regarding your example, my old C compiler (which is a fraction the   
   >>>> size of this new Cdecl) 'explains' it as:   
   >>>>   
   >>>>     'ref proc(int)ref proc()void'   
   >>>>   
   >>>> (Not quite English, more Algol68-ish.)   
   >>> Can I run your old C compiler on my Ubuntu system?   
   >>>   
   >>   
   >> The old one needed a tweak to bring it up-to-date for my newer C   
   >> transpiler. So it was easier to port the feature to the newer product.   
   >>   
   >> Download https://github.com/sal55/langs/blob/master/ccu.c   
   >>   
   >> (Note: 86Kloc/2MB file; this is poor quality, linear C generated from   
   >> intermediate language.)   
   >>   
   >> Build instructions are at the top. Although this targets Win64, it   
   >> works enough to demonstrate the feature above. Create this C file (say   
   >> test.c):   
   >>   
   >>    int main(void) {   
   >>        void (*f(int i))(void);   
   >>        $showmode f;   
   >>    }   
   >>   
   >> Run as follows (if built as 'ccu'):   
   >>   
   >>    ./ccu -s test   
   >>   
   >> It will display the type during compilation.   
   >>   
   >> Obviously this is not a dedicated product (and doing the reverse needs   
   >> a separate program), but I only needed to add about 10 lines of code   
   >> to support '$showmode'.   
   >>   
   >> Original source, omitting the unneeded output options, would be 2/3   
   >> the size of that configure script.   
   >   
   > OK, I was able to compile and run your ccu.c, and at least on this   
   > example it works as you've described it.  It looks interesting,   
   > but I personally don't find it particularly useful, given that I   
   > already have cdecl, I prefer its syntax, and it's easier to use   
   > (and I almost literally could not care less about the number of   
   > lines of code needed to implement cdecl).   
      
      
   Well I built cdecl too, under WSL. Jesus, that looked a lot of work!   
      
   However, it took me a while to find where it put the executable, as the   
   make process doesn't directly tell you that. It seems it puts it inside   
   the src directory, which is unusual. It further appears that you have to   
   do 'make install' to be able to run it without a path.   
      
   (Yes, I did glance at the readme, but it is a .md file which I didn't   
   notice, and in plain text it looked unreadable.)   
      
   When I did run it, then while it had a fair number of options, it didn't   
   appear to do much beyond converting C declarations to and from an   
   English description.   
      
   That program is 2.8 MB (10 times the size of my C compiler).   
      
   I guess you don't care about that either. But surely, you must be   
   curious about WHY it is so big? You must surely know, with your decades   
   of experience, that this is 100 times bigger than necessary for such a task?   
      
      
   I decided to make my own mini-cdecl. It took 20 minutes and works like this:   
      
      c:\cx>qq cdecl   
      Mycdecl> explain void (*f(int i))(void);   
      f = proc(i32)ref proc()void   
      Mycdecl> q   
      
   It relies on a new feature of my C compiler, an extra linkage kind to go   
   with 'typedef' and 'static', called '$showtype'. When used, it displays   
   the type of the name being declared, and then stops compilation.   
      
   That allows me to invoke it from the script shown below. It doesn't do   
   'declare' though.   
      
      
   -----------------------------------------   
   do   
        print "Mycdecl> "   
        readln cmd:"n", rest:"l"   
      
        case cmd   
        when "explain" then   
            explaintype(rest)   
      
        when "x", "q", "exit" then   
            stop   
        else   
            println "?"   
        esac   
   od   
      
   proc explaintype(ctype)=   
        writestrfile("$temp.c", "$showtype "+ctype+";")   
        if system("cc $temp.c >result") = 0 then   
            println readtextfile("result")[2]   
        else   
            println "Error"   
        fi   
   end   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca