Bug 51104 - C++ support about httpd_config.h
Summary: C++ support about httpd_config.h
Status: REOPENED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: support (show other bugs)
Version: 2.4.16
Hardware: All Linux
: P2 major (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-21 18:25 UTC by Torden Cho
Modified: 2017-03-02 11:18 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Torden Cho 2011-04-21 18:25:07 UTC
Hi All,
This is Torden Cho, I doing development little module base on C++.

Current I doing 1.3 api migration 2.x api however I have a problem in http_config.h

that's line is below

159: typedef const char *(*cmd_func) ();

and below is g++ error message.

error: invalid conversion from ‘const char* (*)(cmd_parms*, void*, const char*)’ to ‘const char* (*)()’

Anyway, I have been self path to http_config.h so therefore I be fine.
I thinks so we providing solution to who c++ module developer.

--- /usr/local/httpd/include/http_config.h      2011-04-22 05:18:19.000000000 +0900
+++ /usr/local/httpd/include/http_config.h.new  2011-04-22 05:17:59.000000000 +0900
@@ -155,7 +155,11 @@
 
 #else /* AP_HAVE_DESIGNATED_INITIALIZER */
 
-typedef const char *(*cmd_func) (cmd_parms *, void *, const char *);
+#ifdef __cplusplus
+typedef const char *(*cmd_func) (cmd_parms *cmd, void *dummy, const char *path);
+#else
+typedef const char *(*cmd_func) ();
+#endif
 
 # define AP_NO_ARGS  func
 # define AP_RAW_ARGS func

Any Idea? Any Suggest?


Thanks Buddy.
--Torden.
Comment 1 Stefan Fritsch 2011-04-25 16:28:18 UTC
The types of the union members differ. Therefore you cannot find a definition for cmd_func that works for all union members. For example, your patch will only work with AP_RAW_ARGS and AP_TAKE1 but not with AP_TAKE2, ...

I think the only valid solution in current C++ is to use a cast.
Comment 2 Masashi Takahashi 2015-10-14 07:39:17 UTC
> I think the only valid solution in current C++ is to use a cast.

C++11 supports designated initializer for union.
So it must be fixed.

Following works fine.

$ diff /usr/include/apache2/ap_config.h /usr/include/apache2/ap_config.h.old
175c175
< #if (defined(__GNUC__) && !defined(__cplusplus)) || (defined(__cplusplus) && 201103L <= __cplusplus) || defined(AP_HAVE_C99)
---
> #if (defined(__GNUC__) && !defined(__cplusplus)) || defined(AP_HAVE_C99)