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,860 other subscribers

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 comment

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