Information Technology - Computer Programming - Source Code - Homebrew - Open Source - Software - Hardware - 8 bit - 16 bit - 32 bit - 64 bit - x86 - x64 - DOS - Windows - Linux - Arduino - Embedded - Development - Retro - Vintage - Math - Science - History - Hobby - Beginners - Professionals - Experiment - Research - Study - Fun - Games

An obfuscated C coding contest

Anything C/C++ related.
admin
Site Admin
Posts: 127
Joined: Wed Feb 22, 2023 6:51 am

Re: An obfuscated C coding contest

Post by admin »

I'm unfortunately still having no luck with compiling. And somehow I accidentally overwrote your last post with this one. I am upset at myself for that one and apologize. No idea how I did that.

Bloodshed uses Mingw which is GCC for Windows. Not sure if that's a problem. The error I get from it is:

Code: Select all

 In function `void enterline()': 
 invalid conversion from `void*' to `char*' 
That's compiling the unobfuscated version. The obfuscated version throws a bunch of errors.

Using bcc55, I am having trouble setting it up. I created the .cfg files and am still getting errors.

The obfuscated version gives me:

Code: Select all

Error E2293 ddsbasic.cpp 14: ) expected
Error E2040 ddsbasic.cpp 14: Declaration terminated incorrectly
*** 2 errors in Compile ***
The unobfuscated version gives me:

Code: Select all

Warning W8060 ddsbasicuo.cpp 38: Possibly incorrect assignment in function main()
Warning W8060 ddsbasicuo.cpp 41: Possibly incorrect assignment in function main()
Warning W8060 ddsbasicuo.cpp 42: Possibly incorrect assignment in function main()
Warning W8060 ddsbasicuo.cpp 43: Possibly incorrect assignment in function main()
Warning W8060 ddsbasicuo.cpp 59: Possibly incorrect assignment in function main()
Warning W8060 ddsbasicuo.cpp 79: Possibly incorrect assignment in function main()
Error E2034 ddsbasicuo.cpp 124: Cannot convert 'void *' to 'char *' in function
enterline()
*** 1 errors in Compile ***
Your modified version gives me:

Code: Select all

Error E2184 ddsbasicmod.cpp 187: Enum syntax error
Error E2040 ddsbasicmod.cpp 187: Declaration terminated incorrectly
Error E2190 ddsbasicmod.cpp 187: Unexpected }
Error E2190 ddsbasicmod.cpp 187: Unexpected }
Error E2034 ddsbasicmod.cpp 325: Cannot convert 'void *' to 'char *' in function enterline(char *)
*** 5 errors in Compile ***
cguy
Posts: 8
Joined: Thu May 25, 2023 9:06 pm

Re: An obfuscated C coding contest

Post by cguy »

admin wrote: Thu Jun 01, 2023 9:37 pm I'm unfortunately still having no luck with compiling. And somehow I accidentally overwrote your last post with this one. I am upset at myself for that one and apologize. No idea how I did that.
What? And with all the toil and sweat I spent on that post :)

No worries - things happen sometimes!
Bloodshed uses Mingw which is GCC for Windows. Not sure if that's a problem. The error I get from it is:

Code: Select all

 In function `void enterline()':
 invalid conversion from `void*' to `char*'
That's compiling the unobfuscated version. The obfuscated version throws a bunch of errors.
You are compiling a C source file as a C++ source file. Possibly Bloodshed must have an option for that.

In C, void pointers can be compared to any other pointer.
But in C++, you can only compare pointers of like types, so void* to char* is an error.

I searched, and it appears to be the -x option, from the command line.

I tested:
g++ dds7.c
dds7.c: In function 'void enterline(char*)':
error: invalid conversion from 'void*' to 'CHARP' {aka 'char*'} [-fpermissive]

And then:

g++ -x c dds7.c

And it compiled fine.

And:

gcc -x c++ dds7.c
dds7.c: In function 'void enterline(char*)':
error: invalid conversion from 'void*' to 'CHARP' {aka 'char*'} [-fpermissive]

And then:

gcc dds7.c

And it compiled fine.

So make sure Bloosshed is using gcc instead of g++. And make sure that if it is setting the source file type, the type is C, not C++.
Using bcc55, I am having trouble setting it up. I created the .cfg files and am still getting errors.

The obfuscated version gives me:

Code: Select all

Error E2293 ddsbasic.cpp 14: ) expected
Error E2040 ddsbasic.cpp 14: Declaration terminated incorrectly
*** 2 errors in Compile ***
The unobfuscated version gives me:

Code: Select all

Warning W8060 ddsbasicuo.cpp 38: Possibly incorrect assignment in function main()
Warning W8060 ddsbasicuo.cpp 41: Possibly incorrect assignment in function main()
Warning W8060 ddsbasicuo.cpp 42: Possibly incorrect assignment in function main()
Warning W8060 ddsbasicuo.cpp 43: Possibly incorrect assignment in function main()
Warning W8060 ddsbasicuo.cpp 59: Possibly incorrect assignment in function main()
Warning W8060 ddsbasicuo.cpp 79: Possibly incorrect assignment in function main()
Error E2034 ddsbasicuo.cpp 124: Cannot convert 'void *' to 'char *' in function
enterline()
*** 1 errors in Compile ***
Ah ha! I just noticed you named the files ".cpp". Don't do that :)
These are C source files. Call them whatever.c.

And then it'll work much better!
admin
Site Admin
Posts: 127
Joined: Wed Feb 22, 2023 6:51 am

Re: An obfuscated C coding contest

Post by admin »

Just getting back to my computer after a very stressful week. My work car has major transmission issues that I have been desperately trying to get fixed.

So, I feel silly now. Your suggestion about the file names being cpp and not c was the issue. All 3 versions now compile using Borland 5.5, including the original, unobfuscated, and your modified version. Still, I was only able to get the original one to compile with Bloodshed as I have it configured.

I will look more at your suggestions and see if I can get better results with Bloodshed. Although at this point, I am more inclined to stick with using Borland.

This is the first time I have seen DDS BASIC compiled. I'm very excited.

What's odd is that Bloodshed compile to 11kb while Bordland compiled to 59kb. Perhaps this is due to a bunch of optimization settings I have set in Bloodshed.
cguy
Posts: 8
Joined: Thu May 25, 2023 9:06 pm

Re: An obfuscated C coding contest

Post by cguy »

admin wrote: Tue Jun 06, 2023 6:01 pm Just getting back to my computer after a very stressful week. My work car has major transmission issues that I have been desperately trying to get fixed.
Yuk! Definitely can identify with the car problems. My wife drives an old clunker that is forever having problems. But the price of new cars - and even used cars - makes it hard to replace it! So frustrating!
So, I feel silly now. Your suggestion about the file names being cpp and not c was the issue. All 3 versions now compile using Borland 5.5, including the original, unobfuscated, and your modified version.
No need to feel silly. You don't know what you don't know!
Still, I was only able to get the original one to compile with Bloodshed as I have it configured.
If you want to share the errors, I'm happy to take a gander at them.
What's odd is that Bloodshed compile to 11kb while Bordland compiled to 59kb. Perhaps this is due to a bunch of optimization settings I have set in Bloodshed.
There is a C runtime library DLL that comes with all versions of 32/64-bit Windows - it was intended for an older version of Microsoft C.
gcc under windows uses it, and it cuts the size of the resulting .exe's by a good bit.

Borland does not use that library, but rather links in its own, which increases the size of the resulting .exe.
admin
Site Admin
Posts: 127
Joined: Wed Feb 22, 2023 6:51 am

Re: An obfuscated C coding contest

Post by admin »

Yuk! Definitely can identify with the car problems. My wife drives an old clunker that is forever having problems. But the price of new cars - and even used cars - makes it hard to replace it! So frustrating!
Replacing cars can be painful.
No need to feel silly. You don't know what you don't know!
I know I'm always amazed by what others know.
If you want to share the errors, I'm happy to take a gander at them.
I looked closer at the errors and realized that they were pointing to the comments. Removing the comments made the code work in Bloodshed. I wonder why.
There is a C runtime library DLL that comes with all versions of 32/64-bit Windows - it was intended for an older version of Microsoft C.
gcc under windows uses it, and it cuts the size of the resulting .exe's by a good bit.

Borland does not use that library, but rather links in its own, which increases the size of the resulting .exe.
It would be interesting to compare the dll to the borland library. Which one is the better library?
cguy
Posts: 8
Joined: Thu May 25, 2023 9:06 pm

Re: An obfuscated C coding contest

Post by cguy »

admin wrote: Thu Jun 08, 2023 5:00 am
There is a C runtime library DLL that comes with all versions of 32/64-bit Windows - it was intended for an older version of Microsoft C.
gcc under windows uses it, and it cuts the size of the resulting .exe's by a good bit.

Borland does not use that library, but rather links in its own, which increases the size of the resulting .exe.
It would be interesting to compare the dll to the borland library. Which one is the better library?
Yep, that would be interesting to compare. It would take a long time to do the compare though. How many functions are in the C runtime library? All the standard I/O functions (stdio), all the string functions, math, memory, etc, basically all the functions listed in the standard C header files.

No idea which one is better. Probably neither one is best in all areas. And, as far as I am aware, gcc under windows can't use the Borland C runtime library, and Borland can't use the msvcrt.dll (the Microsoft C runtime library).
admin
Site Admin
Posts: 127
Joined: Wed Feb 22, 2023 6:51 am

Re: An obfuscated C coding contest

Post by admin »

I think you're probably right in that neither one is better in all areas. The fact that there's an alternative to the Microsoft library is a good enough reason alone.

Still, it would be valuable knowledge to break down the differences from a low level code perspective. Not an easy task.
Post Reply