Module for FreeRADIUS wirtten in C++
Hi. I have written a module for FreeRADIUS in C++. Now I have a big problem with compilation. When I am trying to compile the attached file by g++ and I have the following error: g++ -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -D_GNU_SOURCE -DNDEBUG -I/usr/local/include -I/usr/include/mysql++ -I/usr/include/mysql -O2 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"src/rlm_tokensms.d" -MT"src/rlm_tokensms.d" -o"src/rlm_tokensms.o" "../src/rlm_tokensms.cpp" In file included from /usr/local/include/freeradius/radiusd.h:30, from ../src/rlm_tokensms.cpp:18: /usr/local/include/freeradius/libradius.h:160: error: expected type-specifier before ‘;’ token /usr/local/include/freeradius/libradius.h:338: error: expected ‘,’ or ‘...’ before ‘operator’ In file included from /usr/local/include/freeradius/radiusd.h:33, from ../src/rlm_tokensms.cpp:18: /usr/local/include/freeradius/conffile.h:94: error: expected ‘,’ or ‘...’ before ‘template’ In file included from ../src/rlm_tokensms.cpp:18: /usr/local/include/freeradius/radiusd.h:243: error: declaration of ‘home_server* auth_req::home_server’ /usr/local/include/freeradius/realms.h:85: error: changes meaning of ‘home_server’ from ‘typedef struct home_server home_server’ /usr/local/include/freeradius/radiusd.h:577: error: expected ‘,’ or ‘...’ before ‘operator’ I am googling about the proper way of compilation values but the only topics I have found, were from year 2002. I am not familiar with mixing C with C++ so I would like to ask You for help. I do not want to rewrite my code for C, because it will be such a loss of my work. -- krzychk2 <krzychk2@tlen.pl>
krzychk2 wrote:
I have written a module for FreeRADIUS in C++. Now I have a big problem with compilation.
C++ adds reserved words like "operator" that are legal to use in C.
I am not familiar with mixing C with C++ so I would like to ask You for help. I do not want to rewrite my code for C, because it will be such a loss of my work.
Is C++ really that different for simple modules? Alan DeKok.
Dnia 2009-07-21, wto o godzinie 11:05 +0200, Alan DeKok pisze:
krzychk2 wrote:
I have written a module for FreeRADIUS in C++. Now I have a big problem with compilation.
C++ adds reserved words like "operator" that are legal to use in C. And any other. It seems I have to change it by hand.
I am not familiar with mixing C with C++ so I would like to ask You for help. I do not want to rewrite my code for C, because it will be such a loss of my work.
Is C++ really that different for simple modules?
Alan DeKok.
This module is not so simple. It provides very complex authorization, authentication and postauthentication methods based on many backend systems. We want to integrate all this systems into one system with simple protocol. The simplest way was to write module in JAVA but taking the advantage of efficiency I have choose C++. In C the code will not be as consistent as I would like. Other scripting languages like python or perl - well maybe it is some kind of solution but now I do not have time for playing with them. -- krzychk2 <krzychk2@tlen.pl>
You might consider trying JRadius to do your FreeRADIUS module in Java. Otherwise, I think you're looking for "extern C" blocks around your C headers in C++ files. On Tue, 2009-07-21 at 19:54 +0200, krzychk2 wrote:
Dnia 2009-07-21, wto o godzinie 11:05 +0200, Alan DeKok pisze:
krzychk2 wrote:
I have written a module for FreeRADIUS in C++. Now I have a big problem with compilation.
C++ adds reserved words like "operator" that are legal to use in C. And any other. It seems I have to change it by hand.
I am not familiar with mixing C with C++ so I would like to ask You for help. I do not want to rewrite my code for C, because it will be such a loss of my work.
Is C++ really that different for simple modules?
Alan DeKok.
This module is not so simple. It provides very complex authorization, authentication and postauthentication methods based on many backend systems. We want to integrate all this systems into one system with simple protocol. The simplest way was to write module in JAVA but taking the advantage of efficiency I have choose C++.
In C the code will not be as consistent as I would like. Other scripting languages like python or perl - well maybe it is some kind of solution but now I do not have time for playing with them.
Dnia 2009-07-21, wto o godzinie 20:09 +0200, wlanmac pisze:
You might consider trying JRadius to do your FreeRADIUS module in Java.
Otherwise, I think you're looking for "extern C" blocks around your C headers in C++ files.
Thanks for the advice with JRadius. Yes, I have considered that. If there will be dramatic functionality change, and we will have some monitoring data of generating latency and load, then I can make some estimates, and take a decision - do it in Java or stay in C++. For now as a start, I have choose the language witch I know, and I know it can produce a fast code. It is quite obvious that, in object thinking way, Java and C++ are very similar languages. So implementing the same algorithms will save the same logic, data flows and class consistency. It will not be as dramatic change as implementing C code in object way C++ or Java. -- krzychk2 <krzychk2@tlen.pl>
Dnia 2009-07-21, wto o godzinie 11:05 +0200, Alan DeKok pisze:
krzychk2 wrote:
I have written a module for FreeRADIUS in C++. Now I have a big problem with compilation.
C++ adds reserved words like "operator" that are legal to use in C. And any other. It seems I have to change it by hand.
I am not familiar with mixing C with C++ so I would like to ask You for help. I do not want to rewrite my code for C, because it will be such a loss of my work.
Not binded to freeradius: usually you have three main issues with C/C++ code: 1. different ABI Solution: write set of functions (outside classes) for calling C++ code with modifier extern "C". write rlm_<code> in C, using this "C" functions and header, which must be same for "C" and "C++" code. 2. different build process, which must call C++ compiler Solutions build C++ code as shared library, and then let 'glue' rlm module will use one. 3. C++ require c++ standard library in LD_LIBRARY_PATH (it's not a big issue, but when you move module to another machine, you can discover other version of c++ standard library: welcome to linux version of .dll hell)
Is C++ really that different for simple modules?
Alan DeKok.
This module is not so simple. It provides very complex authorization, authentication and postauthentication methods based on many backend systems. We want to integrate all this systems into one system with simple protocol. The simplest way was to write module in JAVA but taking the advantage of efficiency I have choose C++.
In C the code will not be as consistent as I would like. Other scripting languages like python or perl - well maybe it is some kind of solution but now I do not have time for playing with them.
-- krzychk2 <krzychk2@tlen.pl>
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
Dnia 2009-07-21, wto o godzinie 21:11 +0300, Ruslan Shevchenko pisze:
Dnia 2009-07-21, wto o godzinie 11:05 +0200, Alan DeKok pisze:
krzychk2 wrote:
I have written a module for FreeRADIUS in C++. Now I have a big problem with compilation.
C++ adds reserved words like "operator" that are legal to use in C. And any other. It seems I have to change it by hand.
I am not familiar with mixing C with C++ so I would like to ask You for help. I do not want to rewrite my code for C, because it will be such a loss of my work.
Not binded to freeradius: usually you have three main issues with C/C++ code:
1. different ABI
Solution: write set of functions (outside classes) for calling C++ code with modifier extern "C".
write rlm_<code> in C, using this "C" functions and header, which must be same for "C" and "C++" code.
2. different build process, which must call C++ compiler
Solutions build C++ code as shared library, and then let 'glue' rlm module will use one.
3. C++ require c++ standard library in LD_LIBRARY_PATH (it's not a big issue, but when you move module to another machine, you can discover other version of c++ standard library: welcome to linux version of .dll hell)
Thanks a lot for Your help. For now I have changed 3 header files : conffile.h libradius.h radiusd.h and changed "operator" to "oper" It seems the module has compiled, linked and it is now working. I will try Your method tomorrow. Now when I am reading it, it is so obvious :) -- krzychk2 <krzychk2@tlen.pl>
participants (4)
-
Alan DeKok -
krzychk2 -
Ruslan Shevchenko -
wlanmac