The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,779 other followers

This is why I try to avoid C, as it means handling code from others that shoot in foots

Posted by jpluimers on 2019/08/07

Via [WayBack] Hello, I’m translating some C code to Delphi and found something that surprise me…is it logical that this code compiles ? – Paul TOTH – Google+

Maintaining C means you need to be aware that other people like shooting at foots (yes, that is a grammar error by intent):

#include 
#include 

void test();

void test2() {
  test();
}

void test(char *msg) {
  printf("test called '%s' (%d)\n", msg, strlen(msg));
}

void main() {
  test2();
}

Of course!? with gcc under Ubuntu the result is

test called 'test' (4)

Code is derived from [Archive.isgit hub user fogleman project Craft search db_worker_start

The thread has some nice comments.

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: