473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How reliable preprocessor output is?

Hello All,

I have one doubt. I got the preprocessor output of registry_servd.c
(one of the source files of my application). In the preprocessor out I
see the "defination" of __sigismember function. But when I do

$ nm -A registry_servd.o | grep __sigismember

I dont see the function name in that .o file.Also as the source file
is a C file I dont think there is anything called as name mangling.
How it is possible that function name is present in preprocessor
output but missing in .o file..???

Can somebody explain me how this can happen.

Thanks
-Raju
Nov 13 '05 #1
5 2070
Vittal <vs*********@yahoo.com> scribbled the following:
Hello All, I have one doubt. I got the preprocessor output of registry_servd.c
(one of the source files of my application). In the preprocessor out I
see the "defination" of __sigismember function. But when I do $ nm -A registry_servd.o | grep __sigismember I dont see the function name in that .o file.Also as the source file
is a C file I dont think there is anything called as name mangling.
How it is possible that function name is present in preprocessor
output but missing in .o file..??? Can somebody explain me how this can happen.


What *exactly* is the "defination" of __sigismember? If it's something
like:
#define __sigismember aWeirdFunctionSomewhereWhoseNameYouDoNotKnow
then of course you won't find the __sigismember symbol anywhere in the
object file.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"As we all know, the hardware for the PC is great, but the software sucks."
- Petro Tyschtschenko
Nov 13 '05 #2
Joona I Palaste <pa*****@cc.helsinki.fi> scribbled the following:
Vittal <vs*********@yahoo.com> scribbled the following:
Hello All, I have one doubt. I got the preprocessor output of registry_servd.c
(one of the source files of my application). In the preprocessor out I
see the "defination" of __sigismember function. But when I do $ nm -A registry_servd.o | grep __sigismember I dont see the function name in that .o file.Also as the source file
is a C file I dont think there is anything called as name mangling.
How it is possible that function name is present in preprocessor
output but missing in .o file..??? Can somebody explain me how this can happen.
What *exactly* is the "defination" of __sigismember? If it's something
like:
#define __sigismember aWeirdFunctionSomewhereWhoseNameYouDoNotKnow
then of course you won't find the __sigismember symbol anywhere in the
object file.


Also, C does not specify the format of the object files. It might very
well be that your linker is using something else than symbol names to
do the symbol matching. Weird - very weird - but certainly possible.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"To err is human. To really louse things up takes a computer."
- Anon
Nov 13 '05 #3
Here is what I see in the preprocessor output.

extern int __sigismember (__const __sigset_t *__set, int __sig) {
unsigned long int __mask = (((unsigned long int)
1) << (((__sig) - 1) % (8 * sizeof (unsigned long int)))); unsigned
long int __word = (((__sig) - 1) / (8 * sizeo
f (unsigned long int))); return (__set->__val[__word] & __mask) ? 1 :
0; }

Actually this piece of code comes from <socket.h> header file and also
the same header file has the DEFINATION of __sigismember function.

Regards
-Raju

Joona I Palaste <pa*****@cc.helsinki.fi> wrote in message news:<bf**********@oravannahka.helsinki.fi>...
Vittal <vs*********@yahoo.com> scribbled the following:
Hello All,

I have one doubt. I got the preprocessor output of registry_servd.c
(one of the source files of my application). In the preprocessor out I
see the "defination" of __sigismember function. But when I do

$ nm -A registry_servd.o | grep __sigismember

I dont see the function name in that .o file.Also as the source file
is a C file I dont think there is anything called as name mangling.
How it is possible that function name is present in preprocessor
output but missing in .o file..???

Can somebody explain me how this can happen.


What *exactly* is the "defination" of __sigismember? If it's something
like:
#define __sigismember aWeirdFunctionSomewhereWhoseNameYouDoNotKnow
then of course you won't find the __sigismember symbol anywhere in the
object file.

Nov 13 '05 #4
Vittal <vs*********@yahoo.com> scribbled the following:
Here is what I see in the preprocessor output. extern int __sigismember (__const __sigset_t *__set, int __sig) {
unsigned long int __mask = (((unsigned long int)
1) << (((__sig) - 1) % (8 * sizeof (unsigned long int)))); unsigned
long int __word = (((__sig) - 1) / (8 * sizeo
f (unsigned long int))); return (__set->__val[__word] & __mask) ? 1 :
0; } Actually this piece of code comes from <socket.h> header file and also
the same header file has the DEFINATION of __sigismember function.


Hmm, I spot several things which might be problems, but could be just
oddities, or a sign of cluelessness on my part.
First, why is that function __sigismember labelled as extern when code
is supplied for it?
Second, you say it comes from a header file. Are you sure this header
file is included anywhere? If it's not, then no wonder it's not going
to the object file. But since you say it comes from preprocessor
output, not input, I am fairly sure it is being included. Just checking
though.
And lastly, as I said before, it just might be that your linker does
not use symbol names in object files at all.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"Life without ostriches is like coffee with milk."
- Mika P. Nieminen
Nov 13 '05 #5
>I have one doubt. I got the preprocessor output of registry_servd.c
(one of the source files of my application). In the preprocessor out I
ANSI C does not define "the preprocessor" as a separate program nor
as something that has output you can see.
see the "defination" of __sigismember function. But when I do
Is it a static function? That doesn't have external linkage.
$ nm -A registry_servd.o | grep __sigismember

I dont see the function name in that .o file.Also as the source file
is a C file I dont think there is anything called as name mangling.
How it is possible that function name is present in preprocessor
output but missing in .o file..???


There is no guarantee that *ANY* function names appear in an object file
in a way that a program called "nm" can see them.

Gordon L. Burditt
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Sabyasachi Basu | last post by:
While trying to port some stuff from Unix to Windows, I encountered a strange behaviour of function macros with empty arguments. Here is a small snippet which illustrates the problem: #include...
0
by: Johnny Willemsen | last post by:
Hi, I have an issue with the preprocessor of Visual Age. I have A.h that includes B.h that includes C.h. When B.h now only contains includes, it is not listed in the preprocessor output as file,...
16
by: Trying_Harder | last post by:
Is it possible to redefine a macro with global scope after undefining it in a function? If yes, could someone explain how? /If/ my question above isn't very clear you can refer to the...
9
by: Walter Roberson | last post by:
I have run into a peculiarity with SGI's C compiler (7.3.1.2m). I have been reading carefully over the ANSI X3.159-1989 specification, but I cannot seem to find a justification for the behaviour....
32
by: spibou | last post by:
Is the output of the C preprocessor deterministic ? What I mean by that is , given 2 compilers which conform to the same standard, will their preprocessors produce identical output given as input...
8
by: mohdalibaig | last post by:
C preprocessor generates the expanded version of our source code. In order to view this expanded code, I made use of the command cpp filename.c on the dos prompt. This command generates a file of...
31
by: Sam of California | last post by:
Is it accurate to say that "the preprocessor is just a pass in the parsing of the source file"? I responded to that comment by saying that the preprocessor is not just a pass. It processes...
5
by: John Speth | last post by:
Hi Group- I want to use the C preprocessor to generate expanded text as a text processor for software test script generation. The preprocessor output will never be compiled. I need to insert...
14
by: lagman | last post by:
All, I'm looking for a tool that is able to take my code base (which is full of preprocessor directives) and spit out source code that is "clean" of any preprocessor directives based on the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.