error when including ISC dhcp-4.2.3 header file(dhcpd.h) to a cpp file.

ameen.shajahan at wipro.com ameen.shajahan at wipro.com
Mon Jan 30 11:56:15 UTC 2012


Contents of test.cpp below
---------------------------------

 #include<stdlib.h>
 #include<string.h>
 #ifdef __cplusplus
     extern "C" {
     #endif
    #include "test.h"

 #ifdef __cplusplus
    }
 #endif

 int main(int argc, char **argv)
  {
  return 0;
  }
----------------------------------

In test.cpp, i changed :

#include "test.h"

to this

extern "C" {
#include "test.h"
}

And the same compilation error mentioned below.
[amin at csc dhcpd_test]$ make
----- Compiling test.cpp
In file included from /home/amin/dhcp-4.2.3/includes/omapip/isclib.h:64,
                 from /home/amin/dhcp-4.2.3/includes/dhcpd.h:95,
                 from test.cpp:8:
/home/amin/dhcp-4.2.3/bind/include/dns/client.h:209: error: parse
   error before `namespace'
/home/amin/dhcp-4.2.3/bind/include/dns/client.h:237: error: parse
   error before `namespace'
In file included from /home/amin/dhcp-4.2.3/includes/dhcpd.h:100,
                 from test.cpp:8:
/home/amin/dhcp-4.2.3/includes/statement.h:69: error: no
   body nor ';' separates two class, struct or union declarations
/home/amin/dhcp-4.2.3/includes/statement.h:69: error: parse
   error before `add'
In file included from /home/amin/dhcp-4.2.3/includes/dhcpd.h:101,
                 from test.cpp:8:
/home/amin/dhcp-4.2.3/includes/tree.h:215: error: parse
   error before `&&' token
/home/amin/dhcp-4.2.3/includes/tree.h:216: error: parse
   error before `||' token
/home/amin/dhcp-4.2.3/includes/tree.h:217: error: parse
   error before `!' token
In file included from /home/amin/dhcp-4.2.3/includes/dhcpd.h:251,
                 from test.cpp:8:
/home/amin/dhcp-4.2.3/includes/failover.h:265: error: ISO
   C++ forbids declaration of `OMAPI_OBJECT_PREAMBLE' with no type
/home/amin/dhcp-4.2.3/includes/failover.h:285: error: ISO
   C++ forbids declaration of `OMAPI_OBJECT_PREAMBLE' with no type
/home/amin/dhcp-4.2.3/includes/failover.h:287: error: '
   omapi_addr_t' is used as a type, but is not defined as a type.
/home/amin/dhcp-4.2.3/includes/failover.h:339: error: ISO
   C++ forbids declaration of `OMAPI_OBJECT_PREAMBLE' with no type
In file included from test.cpp:8:
/home/amin/dhcp-4.2.3/includes/dhcpd.h:416: error: no
   body nor ';' separates two class, struct or union declarations
/home/amin/dhcp-4.2.3/includes/dhcpd.h:416: error: parse
   error before `classes'
/home/amin/dhcp-4.2.3/includes/dhcpd.h:476: error: ISO
   C++ forbids declaration of `OMAPI_OBJECT_PREAMBLE' with no type
/home/amin/dhcp-4.2.3/includes/dhcpd.h:495: error: ISO
   C++ forbids declaration of `OMAPI_OBJECT_PREAMBLE' with no type
/home/amin/dhcp-4.2.3/includes/dhcpd.h:506: error: no
   body nor ';' separates two class, struct or union declarations
/home/amin/dhcp-4.2.3/includes/dhcpd.h:506: error: parse
   error before `billing_class'
/home/amin/dhcp-4.2.3/includes/dhcpd.h:838: error: ISO
   C++ forbids declaration of `OMAPI_OBJECT_PREAMBLE' with no type
/home/amin/dhcp-4.2.3/includes/dhcpd.h:863: error: ISO
   C++ forbids declaration of `OMAPI_OBJECT_PREAMBLE' with no type
/home/amin/dhcp-4.2.3/includes/dhcpd.h:897: error: no
   body nor ';' separates two class, struct or union declarations
/home/amin/dhcp-4.2.3/includes/dhcpd.h:897: error: parse
   error before `class'
/home/amin/dhcp-4.2.3/includes/dhcpd.h:902: error: ISO
   C++ forbids declaration of `OMAPI_OBJECT_PREAMBLE' with no type
/home/amin/dhcp-4.2.3/includes/dhcpd.h:928: error: ISO
   C++ forbids declaration of `OMAPI_OBJECT_PREAMBLE' with no type
/home/amin/dhcp-4.2.3/includes/dhcpd.h:948: error: ISO
   C++ forbids declaration of `OMAPI_OBJECT_PREAMBLE' with no type
/home/amin/dhcp-4.2.3/includes/dhcpd.h:964: error: no
   body nor ';' separates two class, struct or union declarations
/home/amin/dhcp-4.2.3/includes/dhcpd.h:964: error: parse



From: dhcp-users-bounces+ameen.shajahan=wipro.com at lists.isc.org [mailto:dhcp-users-bounces+ameen.shajahan=wipro.com at lists.isc.org] On Behalf Of Jeff Waller
Sent: 30 January 2012 16:59
To: Users of ISC DHCP
Subject: Re: error when including ISC dhcp-4.2.3 header file(dhcpd.h) to a cpp file.

Could you list the contents of test.cpp

And I'm going to take a guess here.  In test.cpp, can you change this:

#include "test.h"

to this

extern "C" {
#include "test.h"
}




On Jan 30, 2012, at 5:56 AM, <ameen.shajahan at wipro.com<mailto:ameen.shajahan at wipro.com>> <ameen.shajahan at wipro.com<mailto:ameen.shajahan at wipro.com>> wrote:


Hi,
                I have one c file , header file and one Makefile , and including ISC DHCP-4.2.3 libraries and header files in a Makefile.

For eg:

[amin at csc dhcpd_test]$ ls

Makefile  test.c   test.h


Contents inside c file and header file below.
------------------------------------
vi test.c

#include<stdlib.h>
 #include<string.h>
 #include "test.h"
int main(int argc, char **argv)
  {
  return 0;
  }
-----------------------
vi test.h

#include<dhcpd.h>

--------------------------
vi Makefile

 EXECUTABLE = dhcp-server
# Sources
 C_SRCS := $(wildcard *.c)
.
.
.
.
.
.
.
.
-------------------------------

And I compiled,
[amin at csc dhcpd_test]$ make
----- Compiling test.c
test.c: In function `main':
test.c:17: warning: unused parameter `argc'
test.c:17: warning: unused parameter `argv'
----- Linking dhcp-server
[amin at csc dhcpd_test]$ ls
dhcp-server  Makefile  test.c  test.h  test.o
[amin at csc dhcpd_test]$


              [its compiling successfully and create a executable called dhcp-server]




But,When I changed test.c to test.cpp and changing CXX_SRCS := $(wildcard *.cpp) in a Makefile
Its not compiling and throws compilation errors.

[amin at csc dhcpd_test]$ ls
dhcp-server  Makefile  test.cpp  test.h

[amin at csc dhcpd_test]$ make
----- Compiling test.cpp
In file included from /home/amin/csc/dhcp-4.2.3/includes/omapip/isclib.h:64,
                 from /home/amin/csc/dhcp-4.2.3/includes/dhcpd.h:106,
                 from test.cpp:7:
/home/amin/csc/dhcp-4.2.3/bind/include/dns/client.h:213: error: parse
   error before `namespace'
/home/amin/csc/dhcp-4.2.3/bind/include/dns/client.h:241: error: parse
   error before `namespace'
In file included from /home/amin/csc/dhcp-4.2.3/includes/dhcpd.h:114,
                 from test.cpp:7:
/home/amin/csc/dhcp-4.2.3/includes/statement.h:69: error: no
   body nor ';' separates two class, struct or union declarations
/home/amin/csc/dhcp-4.2.3/includes/statement.h:69: error: parse
   error before `add'
In file included from /home/amin/csc/dhcp-4.2.3/includes/dhcpd.h:115,
                 from test.cpp:7:
/home/amin/csc/dhcp-4.2.3/includes/tree.h:215: error: parse
   error before `&&' token
/home/amin/csc/dhcp-4.2.3/includes/tree.h:216: error: parse
   error before `||' token
/home/amin/csc/dhcp-4.2.3/includes/tree.h:217: error: parse
   error before `!' token
In file included from test.cpp:7:
/home/amin/csc/dhcp-4.2.3/includes/dhcpd.h:431: error: no
   body nor ';' separates two class, struct or union declarations
/home/amin/csc/dhcp-4.2.3/includes/dhcpd.h:431: error: parse
   error before `classes'
.

.
.
.
.

.




What would be the problem..
Please let me know.
But I actually need test.cpp and CXX_SRCS := $(wildcard *.cpp) to compile .



Thanks,
Ameen S
















Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com<http://www.wipro.com>
_______________________________________________
dhcp-users mailing list
dhcp-users at lists.isc.org<mailto:dhcp-users at lists.isc.org>
https://lists.isc.org/mailman/listinfo/dhcp-users


Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. 

www.wipro.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20120130/0343d4d8/attachment.html>


More information about the dhcp-users mailing list