- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Considering that the binary will come out of the compiler in pretty much the same way, the c method saves a lot of time and headaches for the sorry son of a bitch that just figured out that he's not programming an x86. Especially if all the makefiles somehow get lost (or are never created). While not incorrect and possibly useful I don't see a wtf in doing it this way. It's hardly "cargo cult" and embedded programming is pretty much black magic anyways.
Maybe I'm just a lazy sack of shit though.
Admin
I think TRWTF is the lack of a document explaining how to build the code.
Admin
...that the submitter knew of.
But then the submitter somehow thinks it's better to send something they don't understand to TDWTF rather than asking a colleague or sending their noob question to stackoverflow.com
I would blame Java schools, but naievity has been around a lot longer than Java (or else Java wouldn't exist...)
Admin
Erm. It's so that the binaries can be pre-built into translation units, which among other things massively reduces linking time and allows for link time modularity and resource replacement.
This is a very common thing in high-end C and C++ development. There's nothing WTF about this at all.
Admin
Another embedded system programmer here agreeing that it is not a WTF, indeed it is more like industry standard procedure. I actually work on agricultural machinery, and I am assuming that the TRS is a Tractor Radar System?
Admin
Drive tractor, fart loudly?
Admin
Ever heard of RLE?
Admin
Is that so weird ? It used to be common. The old XBM and XPM image file formats were in fact... C
Maybe the WTF is that those formats were not used ?
Admin
True WTF is this whole topic, showing the current state of programming world: loads of developers saying ("reimplementing") the same thing in slightly different redundant ways instead of actually checking what other people have written.
Admin
I guess this can be considered proof that there is intelligent life on earth.
Admin
I don't quite see the problem - I admit it is not too easy to exchange images, sure. But gimp can easily save images as C files (the output looks kind of similar). I used this too when I was to lazy to add a image file parser in college.
(damn windows static heap sice was often too small though when porting the stuff)
Admin
Guys, this isn't really bad. If they were working in an embedded environment, one where a filesystem might not be available, then this is perfectly reasonable. I just wanted to make that clear before the discussion got too heated.
Admin
Yes.
Tell me what it has to to with the standard output of a bmp2c converter exe?
Admin
[quote user="Doug"] Considering that the binary will come out of the compiler in pretty much the same way, the c method saves a lot of time and headaches for the sorry son of a bitch that just figured out that he's not programming an x86. [/code] Are you implying x86 is the only target supported by GCC / GNU binutils?
[quote user="Doug"] Especially if all the makefiles somehow get lost (or are never created). [/code] Are you still arguing "not a WTF"?
How about: [quote] Especially if the C-Compiler somehow get lost (or never existed). [/code] (seems to me on the same level of absurdness).
[quote user="Doug"] It's hardly "cargo cult" and embedded programming is pretty much black magic anyways. [/quote] Accepting such cargo cult voodoo as "industrial practice" instead of using tools that directly support what is needed is exactly what makes embedded programming black magic.
Why pay a commercial manufacturer of embedded system processors a shitload of money for a dev kit whose linker is unable to simply include a binary file in an executable?
Instead of chosing a different one or telling the manufacturer that this feature is required, those developers wasted their time in implementing a binary to C-converter only to complicate and slowdown the build process!
Admin
[quote user="Design Pattern]...telling the manufacturer that this feature is required...[/quote]
HaHaHaHaHA!
Admin
1: Hardly, I've written a GEM myself. Also, are you implying GCC is the only c compiler in use?
2/3: It isn't really comparable. There are ISAs that, while rare, don't even have c compilers! Sometimes people do silly things (even your coworkers!), but the "c-bitmap" surely didn't hurt anything.
4: I wouldn't exactly consider this example to be "black magic" either, considering a new programmer could probably put two and two together without too much trouble. I'm sure you know some things will get a bit trickier.
If I'm not mistaken, MPLAB is actually free. I'm certain you could probably do it your way with Microchips tools too.
MCU's are often specialized, or already in the design. You can't always just get a different one. The above programmer didn't create that bitmap to c converter, it already exists. And it seems to me that it actually makes the build process simpler, and probably not too much slower. The compiler would even align it for you!
Admin
It's actually a standard format for bitmaps. The author of the letter should read more.
Admin
The WTF is that you post this as a WTF. It is perfectly normal to do that.
Admin
Did you submit this WTF? Because you seem to have some idea of embedded programming, but obviously not a lot of real world experience with it.
"Look boss, I know it would take me twenty minutes to write a well tested binary converter, but I refuse to. YOU need to get on the phone and tell Motorola that we demand they build it themselves! And they won't get any more of our money until they do! In the mean time I'll be spending the next two hours building binutils, after three days of getting gcc to produce code for our target, and then probably the rest of the project finding code gen bugs. Where's my paycheck?"
Admin
This is actually used when compiling stuff to be run on NDSs or GBAs. There is even a utility, grit, (http://www.coranac.com/projects/) to convert things to them. It is necessary because all the files need to be linked into one binary.
Similar cases might show up in other low level devices without a OS or filesystem.
Admin
This is the preferred way of storing images when writing GBA carts, and the same probably holds true for older nintendo cartridge systems.
Admin
Why do you assume the devs wasted their time implementing a converter? Maybe they
The submitter already got it wrong that the code is a WTF, I doubt he has any clue about how it was generated. Again, he seemed happier to rush it to TDWTF than to ask his colleagues or stackoverflow and learn something about his profession.
Admin
Why do you assume the devs wasted their time implementing a converter? Maybe they
The submitter already got it wrong that the code is a WTF, I doubt he has any clue about how it was generated. Again, he seemed happier to rush it to TDWTF than to ask his colleagues or stackoverflow and learn something about his profession.
Admin
It was all the rage in the ancient days... http://en.wikipedia.org/wiki/X_PixMap http://en.wikipedia.org/wiki/X_BitMap
Apparently, it was WWW standard :)
Admin
Meh. I'm an embedded developper myself, so I can sympathise with the original developer. Lots of embedded systems don't have a file-system. No fopen(), fread(), whatever. Thus you have to include your static data directly into your binary. I like to use objdump to convert arbitrary data to object files I can easily include in an executable. (see also: windows resource files)
Admin
I won't. But you should know what it has to do with the annoyingly large amount of uselessly repetitive data you posted.
Admin
Hey Design Pattern stop using terms (cargo cult) that you don't understand.
I've been writing C and C++ code for 16 years for everything from painful pure win32 API apps to painless cross platform wxWidgets applications (Did i mention XPM's are GREAT for cross platform GUI coding? It is the simplest solution to giving you a consistent way of addressing them.) to game programming, to working on major financial systems.
You sound like someone who read the book on Design Patterns and then the one that discusses anti patterns and DIDN'T ACTUALLY UNDERSTAND THEM.
You're surrounded by gods of programming (embedded programmers) and you're demonstrating your ignorance.
Let me give you some advice, son: SHUT YOUR IGNORANT PIE HOLE.
/PS: when you get out of the kiddie pool (aka Java and C#.NET) come back and try talking to the guys in this thread who are working in microsubs in the Marianas Trench (embedded programmers)
Admin
As a former embedded systems engineer (8051 derivative microcontrollers FTW,) has anyone mentioned that this isn't a WTF at all, but a fairly common practice?
They have?
Oh.
Well, has anyone mentioned that the real WTF is that they employed this idiot?
Admin
This may not be WTF, because the most-portable-of-all game library Allegro works like this. It have a tool which you can use to convert a bitmap image to C code. Bitmap is usually loaded from a database, or file, and converted to a format usable by Allegro. Converting it to C file, all this operations are redundant, and everything runs much faster. And game file grows larger, but this is acceptable, if your issue is speed.
Admin
All I can see is the best solution for including an image in an embedded device. WTWTF?
Admin
The real WTF is the redundant comment noise that this post has generated. Also, whoever let this go on the frontpage is a n00b who never dealth with a microcontroller.
Admin
This actually isn't that uncommon. It could be to make avoid using fancy resource tools that might not be portable across compilers, or it could be to have the code in version management, who knows.. but I've seen it numerous times on numerous platforms in multiple languages.
Admin
Actually, that's a relatively common technique in environments where you don't have something like a Resource Compiler to incorporate binary resources (often images) into your final executable and you don't want to rely on loading them from files at runtime.
Admin
What's new? X pixmaps have been C arrays for decades. http://en.wikipedia.org/wiki/X_PixMap
Admin
@SP: Thanks! I think it's some kind of levitating car :)
Admin
For the ancient cross compilers, this makes perfect sense.
Normally, you'd store bitmaps into disk files or resources, but embedded systems of old had none of that. ROM, RAM, and that was it, no file system. Converting bitmaps and similar data to C initializers was the only way, I've done that more than once.
Admin
The real WTF is 5 pages of replies of people all saying the same thing!
Admin
As an embedded developer you very often find that there isn't actually a filesystem to read external resources from. Where this is the case, it makes perfect sense to define your resources as arrays of image data; indeed, there may be no other option. I don't know if anyone has pointed this out yet.
Admin
That has also been pointed out, repetitively.
Admin
Admin
This all seems pretty reasonable. Where else are you going to put bitmaps in a small device with no filesystem? The implementation is a bit clunky (3 separate structs with the same name is awkward), but the basic idea is sound.
Of course, I'd hope the build system generates these .c/.h files from the original bitmaps as part of the build process...
Admin
Wtf indeed! You are crazy. Crazy enough to join doctor steels army, do not mark as spam please, join now for a utopian playland
Admin
Wtf indeed! You are crazy. Crazy enough to join doctor steels army, do not mark as spam please, join now for a utopian playland
Admin
The real WTF is that they used the BMP format which is almost as retarded as a raw bitmap format can be. The only way to beat that WTF would have been using ZX spectrum screen images. int .height int .width char[] .data
Admin
The person who reported this as a wtf should had been fired on the spot for gross incompetence, that is the only wtf i see here.
Admin
That would need twice as much memory: the memory space for the original file, and some space to copy it into while you're using it. Also, the device it's targetted at may not actually have enough RAM to hold a copy of the bitmap, it may only fit in the ROM that the code is stored in. So why not just hard code it in the in-memory format your bitmap display code will use, as this seems to have done? Skip the loading stage, save RAM, make the display faster, and just take a little bit extra development time to write the .bmp-to-.c converter.
Admin
err, bmp files are nasty if you actually want to handle them properly...
Admin
Yes no makefile is a WTF, but the c-bitmap is not
Admin
shrug let me say, I had to do something very similar, at least with the header part. n-th byte adjustments, compiler balking at or ignoring #pragma PACK and the likes, I finally gave up all structured approaches and did the straightforward thing.
Admin
try getting an 8 pin micro-controller (its a PIC with a watered down bootloader done by rev-ed AKA PICAXE) with 4 outputs, decode 32 ASCII characters and drive 8 seven segment displays with decimal points, I have got one of these to decode the 10 ASCII numbers, colons, 20 different letters and the bell character, it'll receive 8 bytes for the display (via 4800 baud serial and displays 8 characters out of the 32 "palette" max) has decimal point selection code, beep's when it receives a bell, and a display control routine, in 256 bytes of program space and using a micro-controller'ed version of BASIC the "font rom" is shared with the program memory in a way it has an embedded "font" for the 7 segments. for me its quite an achievement. controlling 64 LEDs and decoding the ASCII to drive said LEDs isnt exactly a small feat for a 8 pin micro-controller
captcha validus: your argumentus is in-validus