473,770 Members | 6,091 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Referencing C header file that has new as param?

Hi,

I am writing a C++ program that needs to include a C header file. The
problem I am having is that a couple
of the functions have 'new' as parameter name:

int kernel_sysctl(s truct proc *p, int *name, u_int namelen, void *old,
size_t *oldlenp, void *new, size_t newlen,
size_t *retval);
int userland_sysctl (struct proc *p, int *name, u_int namelen, void
*old,
size_t *oldlenp, int inkernel, void *new, size_t newlen,
size_t *retval);

Is there any way to include this file without my C++ compiler failing
because if this?

Andre

Sep 20 '06 #1
3 1674
an***********@g mail.com wrote:
Hi,

I am writing a C++ program that needs to include a C header file. The
problem I am having is that a couple
of the functions have 'new' as parameter name:

int kernel_sysctl(s truct proc *p, int *name, u_int namelen, void *old,
size_t *oldlenp, void *new, size_t newlen,
size_t *retval);
int userland_sysctl (struct proc *p, int *name, u_int namelen, void
*old,
size_t *oldlenp, int inkernel, void *new, size_t newlen,
size_t *retval);

Is there any way to include this file without my C++ compiler failing
because if this?
I think you're screwed short of the preprocessor. You might try:

#define new
#include "C_Header_file. h"
#undef new
Sep 20 '06 #2
an***********@g mail.com wrote:
Hi,

I am writing a C++ program that needs to include a C header file. The
problem I am having is that a couple
of the functions have 'new' as parameter name:

int kernel_sysctl(s truct proc *p, int *name, u_int namelen, void *old,
size_t *oldlenp, void *new, size_t newlen,
size_t *retval);
int userland_sysctl (struct proc *p, int *name, u_int namelen, void
*old,
size_t *oldlenp, int inkernel, void *new, size_t newlen,
size_t *retval);

Is there any way to include this file without my C++ compiler failing
because if this?
I usually do not work with header files, so I have no idea about best
practices, but the following rather reckless method comes to mind: rewrite
the header -- the names of the parameters are not part of the function
signatures; thus, linking should still work. (Of course, your make tools
might bitch about file modification times, so you may want to keep the
original header. Also, you may not be allowed to do this for legal reasons
[creating a derivative work, etc.].)
Best

Kai-Uwe Bux
Sep 20 '06 #3
The only catch here is that the header is part of the FreeBSD header
file
"sys/sysctl.h":

http://fxr.watson.org/fxr/source/sys/sysctl.h

I could change it for myself, but if anyone else attempts to compile my
code then
they would have to modify the system headers. There must be a better
way.

Andre

Kai-Uwe Bux a écrit :
an***********@g mail.com wrote:
Hi,

I am writing a C++ program that needs to include a C header file. The
problem I am having is that a couple
of the functions have 'new' as parameter name:

int kernel_sysctl(s truct proc *p, int *name, u_int namelen, void *old,
size_t *oldlenp, void *new, size_t newlen,
size_t *retval);
int userland_sysctl (struct proc *p, int *name, u_int namelen, void
*old,
size_t *oldlenp, int inkernel, void *new, size_t newlen,
size_t *retval);

Is there any way to include this file without my C++ compiler failing
because if this?

I usually do not work with header files, so I have no idea about best
practices, but the following rather reckless method comes to mind: rewrite
the header -- the names of the parameters are not part of the function
signatures; thus, linking should still work. (Of course, your make tools
might bitch about file modification times, so you may want to keep the
original header. Also, you may not be allowed to do this for legal reasons
[creating a derivative work, etc.].)
Best

Kai-Uwe Bux
Sep 20 '06 #4

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

Similar topics

2
4368
by: Simon Stuber | last post by:
Hello, I'm using Docbook XML 4.2 and FOP 0.20.5 to create a pdf from my xml source. I can generate the pdf with no problem, however I could not manage to include our company logo within the header. The pdf is created with the correct header, but there is no image. What I did: I copied the whole header.template section from pagesetup.xsl into my
11
2812
by: Milind | last post by:
Hi, I was trying to implement a composition relation, somthing of the following type: class A { public: class B {
6
11300
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header" Src="WebControls/Header.ascx" %> The web user control contains the following server controls
6
1417
by: dana lees | last post by:
Hello, I am developing a c# asp.net application. I have 2 forms. In the first webform ('header') i have a label. I want to reference that label from a different form ('user'), in order to change its' text. How can i do that?
0
1383
by: Frank | last post by:
I am attempting to convert an asp file to a asp.net file using C#. The original file has an ActiveX control which is contained in a cab file. The cab file contains the .ocx file which connects to a socket and transfers client info to a server, as well as several .dlls The cab file also references another cab file which contains files to install on the client machine in case they do not have VBRuntime6 installed on their machine.
4
2124
by: MikeJ | last post by:
make a While loop ofs = TextFileServer("somefile") string srow while (ofs=false) { srow=ofs.getRow(); Console.Writeline(srow); }
2
1983
rajiv07
by: rajiv07 | last post by:
Hi to all I have a script to get geo IP which is successfully running on Linux server.but when i run this script on windows server it gives some header error #!C:/Perl/bin/perl.exe use CGI qw/:standard/; use LWP::UserAgent; use HTTP::Request qw(GET POST); use HTTP::Headers;
6
1194
by: Lars Uffmann | last post by:
Hi everyone, I'm trying to execute the same function call with 1 parameter different in a switch statement of a member function. However, if a certain condition is true (and I can check that before the switch statement), I want to execute a difference function call with the same parameters. So instead of using an if-clause to distinguish the 2 cases in each case-statement, or doubling the switch, I considered this:
3
1814
by: Tony Johansson | last post by:
Hello! I have a class called Simple Editor below where most of it is from a book that I'm reading. If I want to add a Header and a Footer to each page printed. We can just as an example want to have the filename printed on beginning and the end of each page printed. can somebody give me a hint how I best accomplish that?
0
9595
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
9432
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
10232
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...
1
10008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8891
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
7420
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
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.