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

  • Context: C/C++ 
  • Thread starter Thread starter Grep
  • Start date Start date
  • Tags Tags
    Function
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
9 replies · 4K views
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:
 
Physics 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:
 
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:)
 
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: