473,699 Members | 2,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using preprocessors - help!!

I have a class which only purpose is to provide services to a variety
of classes in other files. The 'manipulator' class is aware of the
other classes only because the header files have been include in its
header file. However, there are times when some of the other classes
are not and will not be dealt with, thus the need to include the header
files does not arrive. To handle this, I have used compiler
preprocessors to prevent the unneeded header files and method
declarations / implementations to be compiled, here is an example:

--- popeye.hpp ---
#ifndef POPEYE_HPP
#define POPEYE_HPP
class popeye{ /*the whole enchilada goes here */};

--- mikey.hpp ---
#ifndef MIKEYMOUSE_HPP
#define MIKEYMOUSE_HPP
class mikey{ /*more cheese senior?*/ };

--- donal.hpp ---
#ifndef DONALDUCK_HPP
#define DONALDUCK_HPP
class duck{ /* para bailar la banba */};

--- manipulator.hpp ---
#ifndef MANIPULATOR_HPP
#define MANIPULATOR_HPP
#ifdef POPEYE_HPP
#include "popeye.hpp "
#endif
#ifdef MIKEYMOUSE_HPP
#include "mikey.hpp"
#endif

#ifdef DONALDUCK_HPP
#include "donal.hpp"
#endif

class manipulator{
private:
..........
protected:
..........
public:
..........
#ifdef POPEYE_HPP
void handle_popeye(c onst popeye&);
#endif

#ifdef MIKEMOUSE_HPP
void handle_mikey(co nst mikey&);
#endif

#ifdef DONALDUCK_HPP
void handle_duck(con st duck&);
#endif
.........
};
#ifdef POPEYE_HPP
void manipulator::ha ndle_popeye(con st popeye& p){/*...*/}
#endif
#ifdef MIKEMOUSE_HPP
void manipulator::ha ndle_mikey(cons t mikey& p){/*...*/}
#endif
#ifdef DONALDUCK_HPP
void manipulator::ha ndle_duck(const duck& p){/*...*/}
#endif
--- main.cpp --
#include "popeye.hpp "
#include "manipulato r"

int main(){
popeye p;
manipulator m;
m.handle_popeye (p); //<<== segmentation fault
return 0;
}

My question is: why is it that if I remove the conditional
preprocessors I don't get a segmentation fault?
T. I. A. F.
(Thank In Advance Folks)

Dec 18 '05 #1
4 1121
In article <11************ **********@g14g 2000cwa.googleg roups.com>,
Jamiil <ja******@netsc ape.net> wrote:
I have a class which only purpose is to provide services to a variety
of classes in other files.
The C language does not have any notion of "class".
class popeye{ /*the whole enchilada goes here */};


That appears to be a C++ question. Please ask in comp.lang.c++ .
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers
Dec 18 '05 #2
Jamiil wrote:
I have a class which only purpose is to provide services to a variety
of classes in other files. The 'manipulator' class is aware of the


This is a group about C which does not have these "classes" you speak
of. Try comp.lang.c++.

Robert Gamble

Dec 18 '05 #3
Thanks folks for your prompt response.
Yes, I know that, but the question is about compiler preprocessors not
about C++; it just happens to be in an hpp file. With a little
imagination one could very quickly convert the example to a C program.
Thanks anyway.

Robert Gamble wrote:
Jamiil wrote:
I have a class which only purpose is to provide services to a variety
of classes in other files. The 'manipulator' class is aware of the


This is a group about C which does not have these "classes" you speak
of. Try comp.lang.c++.

Robert Gamble


Dec 19 '05 #4
"Jamiil" <ja******@netsc ape.net> writes:
Robert Gamble wrote:
Jamiil wrote:
> I have a class which only purpose is to provide services to a variety
> of classes in other files. The 'manipulator' class is aware of the


This is a group about C which does not have these "classes" you speak
of. Try comp.lang.c++.

Thanks folks for your prompt response.
Yes, I know that, but the question is about compiler preprocessors not
about C++; it just happens to be in an hpp file. With a little
imagination one could very quickly convert the example to a C program.

Thanks anyway.


Please don't top-post. Your response goes below any quoted text.

You posted C++ code. The folks in comp.lang.c++ can help you with it.

If you want help with a C code, you'll need to post some; we won't
convert it for you.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Dec 19 '05 #5

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

Similar topics

6
6939
by: Clara | last post by:
Hi,... I meant to write an application where there is a button in a window and when you click on the button, it will open a new window, but I want the first window to close, replaced by the second window. I open a login window and start the mainloop, when the user click on the login button, the __call__ function of VerifyProcessor is executed and it will call the new window which is the file manager window The thing is,.. I don't know how...
0
829
by: Timothy V | last post by:
Hi, I'm having trouble working this out and was wondering if anyone could help me. I have a query: SELECT 1 AS Tag, NULL AS Parent, classID AS , className AS FROM Classes FOR XML EXPLICIT;
0
1723
by: Rajesh Jain | last post by:
I Have 2 separate schemas. --------------Schema 1 is defined as below----------- <xs:schema targetNamespace="http://Schemas/1" xmlns="http://Schemas/1" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Loan"> <xs:complexType> <xs:sequence> <xs:element name="Borrower" maxOccurs="unbounded"> <xs:complexType> <xs:attribute name="BorrID" use="required">
6
15505
by: Chua Wen Ching | last post by:
Hi there, I had this xml file with me (not yet consider implementing xml namespaces yet). <?xml version='1.0'?> <Object> <Windows> <EID>1</EID> <EDesc>Error 1</EDesc> </Windows>
1
1154
by: cranker | last post by:
No matter how I fill in parameters for the CreateProcess API, I keep getting a NullReference exception thrown at me when my code executes It's driving me nuts! Can anyone help?
1
2102
by: blinkrebel | last post by:
Hello I need some help implementing the game of blackjack using the xturtle package. the instructions can be found at http://katie.luther.edu/moodle/file.php/2387/BlackJack.pdf and .gif's for the cards can be found at http://katie.luther.edu/moodle/file.php/2387/cards.zip
2
1263
by: CharlesHawk | last post by:
HI i am working on a Project where i have to send a string using Sessions to the next page this is working gud for now But i can convert session to a string the .ToString(); and the Convert.ToString(.....); is not workin I am using Web Matrix . Please Help me ASAP. tanx
1
3406
by: jrw133 | last post by:
So i was given this program in class. i am supposed to create a four-function calculator for fractions using a fraction class. Heres what the requirements are:create a member function for each of the four arithmetic operations. For example fadd(), fsub(), fmul() and fdiv(). these member functions iwll each take 1 argument(of type fraction) and return an object of type fraction. your class should provide member functions for input and output....
0
1152
by: Vicky77 | last post by:
Hi, I need help on calling a program or a command line compiler to compile a program written in a textbox of my IDE. Ok, there's a button called build. If the button is clicked by the user, the program written by the user will be compiled by the compiler and the status of the program (success or fail) should be returned to display( act as normal IDE that we all got use, but i want very basic). So how do i call the other program which is...
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9171
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.