www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/02/20:23:38

From: ams AT ludd DOT luth DOT se (Martin Str|mberg)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: __ctr0_glob_function() doesn't get called in C++
Date: 2 Jan 1999 22:55:02 GMT
Organization: University of Lulea, Sweden
Lines: 38
Message-ID: <76m846$qe6$1@news.luth.se>
References: <3 DOT 0 DOT 5 DOT 32 DOT 19990102175801 DOT 007ab6c0 AT 200 DOT 252 DOT 238 DOT 1>
NNTP-Posting-Host: queeg.ludd.luth.se
X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Thiago F.G. Albuquerque (thiagofga AT ambr DOT com DOT br) wrote:
: The documentation says one could disable the command line wildcard
: expansion by providing a __ctr0_glob_function() that always returned NULL.
: But I found out this only works with C source files. This can be tested
: this way:
: 
: #include <stdio.h>
: 
: char **__crt0_glob_function(char *_argument)
: {
:  printf("This is __crt0_glob_function\n");
:  return NULL;
: }
: 
: int main(int argc, char *argv[])
: {
:  int i;
:  for(int i=0; i<argc; i++)
:       printf("%s\n", argv[i]);
: 
:  return 0;
: }
: 
: save this as glob.c, compile it and run. Then rename the source file to
: glob.cpp and rebuild it. You will notice the C version prints the message,
: while the C++ doesn't.
: 
: Is there a way around this?

I'm no expert on C++, but it seems you have to declare
__crt0_glob_function() as "extern C" (or whatever it's called - that's
how small a C++ expert I am) or put it in a file compiled as C not
C++. It's a C function not a C++ function. 


Holmboe, Symphony No. 6,

							MartinS

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019