473,322 Members | 1,510 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,322 software developers and data experts.

Using a C++ class in C source file

Hi all,

I created a C1.hpp and C1.cpp, compiled and linked into a C1.a
file. I did copy the C1.a file into /usr/local/apache2/lib and
C1.hpp into /usr/local/apache2/include. This class provides
some usefull methods to process a request.

OK. Now I would like to use it in my module mod_xyz.
Entering the command

/usr/local/apache2/bin/apxs -c -i -a mod_xyz.c

returns these lines:

/usr/local/apache2/build/libtool --silent --mode=compile gcc3
-prefer-pic
-DAP_HAVE_DESIGNATED_INITIALIZER -DLINUX=2 -D_REENTRANT
-D_XOPEN_SOURCE=500 -D_BSD_SOURCE
-D_SVID_SOURCE -D_GNU_SOURCE -g -O2 -pthread
-I/usr/local/apache2/include
-I/usr/local/apache2/include -I/usr/local/apache2/include -c -o
mod_xyz.lo mod_xyz.c && touch
mod_xyz.slo
In file included from mod_xyz.c:4:
/usr/local/apache2/include/C1.hpp:6: parse error before "C1"
/usr/local/apache2/include/C1.hpp:7: syntax error before '{' token
/usr/local/apache2/include/C1.hpp:20: syntax error before "int"
/usr/local/apache2/include/C1.hpp:27: syntax error before "int"
/usr/local/apache2/include/C1.hpp:33: syntax error before "int"
/usr/local/apache2/include/C1.hpp:39: syntax error before "void"
/usr/local/apache2/include/C1.hpp:46: syntax error before "int"
/usr/local/apache2/include/C1.hpp:53: syntax error before "char"
/usr/local/apache2/include/C1.hpp:55: parse error before ':' token
apxs:Error: Command failed with rc=65536
..

How can I fix it?
-----------------

László Graf
Nov 14 '05 #1
1 1105
You cannot have a C++ class in a C source file. Just rename the .c file
to
..cpp and compile again.

Also need to be careful about sharing globals between C and C++. Use
extern "C" in C++ code for any variables that are shared with C code.

Deepa
--
EventStudio 2.5 - http://www.EventHelix.com/EventStudio
Generate and auto layout Sequence Diagrams in PDF and MS Word

Nov 14 '05 #2

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

Similar topics

19
by: Dave | last post by:
Hi, I have done some research, trying to Clear The Screen in java code. The first option was the obv: system.out.print("\n\n\n\n\n\n\n\n\n\n\n\n"); then i heard about this method:...
0
by: Jari Kujansuu | last post by:
I am trying to learn to use jing through JARV interface and I have read JARV User's Guide (http://iso-relax.sourceforge.net/JARV/JARV.html). I have downloaded jingjarv-examples.zip from JARV...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
4
by: Bart de Vries | last post by:
Hello, I new on developing with ASP.NET and i wrote some lines of code. This works fine when all the code is in one page, but when i split it up into and ASPX file and make an DLL using a...
2
by: Manish Naik | last post by:
Hi, Using ASP.Net, I want to store and retrive documents (Word, excel, etc) from SQL Server 2000 database. I have tried image type data field, but could not succed. Can any one help me please. ...
9
by: Fat Elvis | last post by:
I'd like to extend some of my Asp.net pages by using Partial Classes. Example ASP.Net Page: public partial class Admin_Customer : System.Web.UI.Page { protected void Page_Load(object sender,...
4
by: Dave Calkins | last post by:
I have a native Win32 C++ app built with Visual Studio 2005. I'd like to make use of a property grid control in this app. For an example of this, in Visual Studio, see the properties control...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
12
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I am a newbie to Struts and JSP...I have been working on the code below for 5 hours now..I googled a lot but couldn't get much help so finally I am here.. Hoping of getting my problem solved. Please...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.