oscarbonilla.com
13Apr/080

Another useless C99 tidbit

From page 18 of the C99 standard:

All occurrences in a source file of the following sequences of three characters (called trigraph sequences) are replaced with the corresponding single character.

??= #    ??( [     ??/ \
??) ]      ??' ^     ??< {
??! |      ??> }    ??- ~

No other trigraph sequences exist. Each ? that does not begin one of the trigraphs listed above is not changed.

Ok, so take the following C program:

??=include <stdio.h>
int
main(int argc, char *argv??(??))
??<
	printf("hello world\n");
??>

And compile it with the -trigraphs switch to gcc:

dirac src $ gcc -trigraphs -o trigraphs trigraphs.c
dirac src $ ./trigraphs
hello world

Combined with this you could seriously obfuscate your C code.

Tagged as: , No Comments
11Apr/081

Hidden Gems in C99 (1)

After some late night reading of the C99 spec, I've found quite a few hidden gems. I'm going to start posting some of these. Since it's late, I'll just post a teaser.

On page 64 of the C99 standard it says:

In all aspects of the language, the six tokens

<: :> <% %> %: %:%:

behave,respectively,the same as the six tokens

[ ] { } # ##

except for their spelling.

Really? Then let's try this program:

%:include <stdio .h>
int
main(int argc, char *argv<::>)
<%
	printf("hello world\n");
%>

Compile it an run it:

dirac src $ gcc main.c
dirac src $ ./a.out
hello world

Whaddaya know... I know, I know... useless. Wait for the next post then.

Tagged as: , 1 Comment
11Apr/080

Haskell

At the intersection between Haskell Programmers and VS.NET Users

Tagged as: , No Comments
1Jul/050

I know how to program in…

I've been reviewing a number of resumes for programming positions because we're hiring programmers and I've started wondering what it means to know a programing language.

For some people it seems it means "I can write hello world in it", and they list dozens of programing languages. From a resume reviewer point of view, this makes it very difficult to see at what level the candidate knows a language. It'd be much better to list only a few and give examples of the programs built on those.

What I'm looking for in a programer basically boils down to this: "can they come up with general purpose abstractions that give the program a self-consistent architecture or do they copy and paste blobs of code to get the job done?".

Tagged as: No Comments