C/C++ Where is this crypt function coming from? (C++)

  • Thread starter Thread starter Grep
  • Start date Start date
  • Tags Tags
    Function
AI Thread Summary
The discussion revolves around a puzzling issue encountered when instantiating a 'crypt' class in C++. The user receives a warning indicating that 'crypt' is being treated as a reference rather than a function call. Despite removing the <stdlib.h> header and not including any C headers, the issue persists, leading to speculation that the g++ compiler might be pulling in symbols from other standard libraries, specifically <iostream> and <string>. It is suggested that this could be a problem with older versions of the gcc compiler, as testing with gcc 4.6 resolves the issue. The conversation also touches on the idea of searching through system headers for the 'crypt' declaration, highlighting the complexities of header file dependencies in C++. The user expresses relief at discovering that the problem is not present in newer compiler versions, indicating a potential bug in gcc 4.4 or earlier.
Grep
Messages
298
Reaction score
3
Helping matumich26 in another thread, I'm running into something puzzling and hoped someone might know what's going on. I must be missing something...

Though 'crypt' is probably a bad name for the class, and the problem is easily avoided by capitalizing the first latter, I still don't know where this crypt function is coming from.

I get this when he tries to instantiate his 'crypt' class:
crypt.cpp:109: warning: statement is a reference, not call, to function ‘crypt’

Now, I've removed the #include <stdlib.h> just in case it's being pulled in from there. Nope, still complains. No C headers included at all.

I took out the 'using namespace std;' and used 'using std::string;' and so on so I don't have the whole std namespace pulled in. Nope, it's not in the std namespace, I guess. Nor can I find a reference to one in documentation.

So I have no C header files included, nor the std namespace. Why the heck is 'crypt' still declared? From the man page for crypt(3) - if that's the culprit - I should need to include unistd.h. It's not.

Anyone know where the heck it's coming from (on a Linux system, BTW)? It's kind of bothering me. :frown:
 
Technology news on Phys.org
I'm afraid that #include <iostream> pulls <unistd.h> in (using g++), even with flag -ansi.

It seems to me that g++ is not entirely ansi-compliant, because it's not supposed to pull symbols in that do not have a leading underscore.
 
I like Serena said:
I'm afraid that #include <iostream> pulls <unistd.h> in (using g++), even with flag -ansi.

It seems to me that g++ is not entirely ansi-compliant, because it's not supposed to pull symbols in that do not have a leading underscore.

Thanks I like Serena, that does indeed appear to be the case. Sort of surprising. I made a small test program and found out that <string> pulls it in. I then tried just <iostream> and it still pulled in the symbol. With no headers included, the problem went away. Bet a lot of the standard libraries have that problem.

I tried to trace it out through the header files, but haven't found it so far. Must be hidden in there somewhere.

I was going to craft a bug report, but I tried it out with gcc 4.6 and the problem is gone. So looks like an issue in 4.4 or other pre-4.6 compilers. Good to see they fixed it!

Anyways, thanks again!
 
Grep said:
I was going to craft a bug report, but I tried it out with gcc 4.6 and the problem is gone. So looks like an issue in 4.4 or other pre-4.6 compilers. Good to see they fixed it!

Anyways, thanks again!

Interesting! :smile:
I'm indeed using gcc version 4.4.3.
 
Have you considered searching /usr/include for a file containing crypt? (Possibly using grep. :-p)

EDIT: Nevermind. See attached file.
 

Attachments

TylerH said:
Have you considered searching /usr/include for a file containing crypt? (Possibly using grep. :-p)

EDIT: Nevermind. See attached file.

Well, duh! :smile:
 
tylerh said:
have you considered searching /usr/include for a file containing crypt? (possibly using grep. :-p)
lol!
 
So when I call grep it's our Grep who does the searching? Wow, you must be busy...:biggrin:
 
jhae2.718 said:
So when I call grep it's our Grep who does the searching? Wow, you must be busy...:biggrin:

I'm in ur computer searchin' ur filez!

(With an apology for writing like a WoW player on trade chat :eek:)
 
  • #10
Grep said:
(With an apology for writing like a WoW player on trade chat :eek:)

You couldn't be--you used the contraction "I'm" correctly :wink:
 

Similar threads

Back
Top