C++ module

shuxinyang shuxinyang.oss at gmail.com
Wed Jun 15 20:45:44 UTC 2016

Quite frankly, I don't know the standard way. My way to tackle this 
problem is to add config.make to the
module like this:


cat config.make
find $ngx_addon_dir -name "*.cc" -print |
     while read x; do
         x=$(basename $x | sed 's/\.cc//')
         cat << __END__ >> $NGX_MAKEFILE
objs/addon/mymodule/$x.o: CFLAGS += -std=c++11


It is to change CFLAGS just for those *.cc of the module in question, 
the CFLAGS for other *.c does
not change. Of course, you need to add -lstdc++ to the lib.

This topic was discussed before, IIRC someone suggested to configure 
nginx with C++ compiler instead
of C compiler. It does not work for me for at least two reasons:

    - there are too many warnings (e.g. c++ compiler is not happy with 
the implicit cast from void* to some-type*)
    - cannot pass c++ specific flags


On 06/15/2016 08:27 AM, Rajalakshmi Iyer wrote:
> Hello,
> Just wanted to check if it is possible to write NGINX modules in C++ 
> that makes extensive use of the standard template library (STL)? If 
> so, what are the things that one needs to be careful about?
> Thanks in advance,
> Raj
> This email and any attachments to it may be confidential and are 
> intended solely for the use of the individual to whom it is addressed. 
> Any views or opinions expressed are solely those of the author and do 
> not necessarily represent those of Blis Ltd, a company registered in 
> England and Wales with registered number 06455773. Its registered 
> office is 5th Floor, 85 Tottenham Court Road, London, W1T 4TQ, United 
> Kingdom.
> If you are not the intended recipient of this email, you must neither 
> take any action based upon its contents, nor copy or show it to 
> anyone. Please contact the sender if you believe you have received 
> this email in error.
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20160615/ab20e1c7/attachment.html>

More information about the nginx-devel mailing list