Opened 12 years ago

Closed 12 years ago

#5030 closed Bugs (invalid)

Windows API declaration mismatch

Reported by: jlcastillo@… Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.45.0 Severity: Cosmetic
Keywords: Cc:

Description

Windows API declaration in Interprocess (win32api.hpp) conflicts with declaration of the same API in other modules. As an example, API function FileTimeToLocalFileTime() is declared in win32api.hpp as:

extern "C" __declspec(dllimport) int  __stdcall FileTimeToLocalFileTime(const interprocess_filetime *in, interprocess_filetime *out);

while in Boost DateTime (filetime_functions.hpp) is declared as:

        __declspec(dllimport) int __stdcall FileTimeToLocalFileTime(const FILETIME* lpFileTime, const FILETIME* lpLocalFileTime);

In MinGW-gcc4.5.0 it shows the following warning:

c:\msys\1.0\local\include\boost-1.45/boost/interprocess/detail/win32_api.hpp:795:138: warning: declaration of 'int boost::interprocess::winapi::FileTimeToLocalFileTime(const boost::interprocess::winapi::interprocess_filetime*, const boost::interprocess::winapi::interprocess_filetime*)' with C language linkage
c:\msys\1.0\local\include\boost-1.45/boost/date_time/filetime_functions.hpp:58:45: warning: conflicts with previous declaration 'int boost::date_time::winapi::FileTimeToLocalFileTime(const boost::date_time::winapi::FILETIME*, boost::date_time::winapi::FILETIME*)'

The warning does not prevent a successful build, but may introduce noise in the build report.

In order to fix it, I changed the following lines in Interprocess win32api.hpp:

extern "C" __declspec(dllimport) int  __stdcall FileTimeToLocalFileTime(const interprocess_filetime *in, const interprocess_filetime *out);

Changed to (removed "extern "C"" and "const"):

__declspec(dllimport) int  __stdcall FileTimeToLocalFileTime(const interprocess_filetime *in, interprocess_filetime *out);
inline bool file_time_to_local_file_time
   (const interprocess_filetime *in, const interprocess_filetime *out)
{  return 0 != FileTimeToLocalFileTime(in, out);  }

Changed to (removed "const"):

inline bool file_time_to_local_file_time
   (const interprocess_filetime *in, interprocess_filetime *out)
{  return 0 != FileTimeToLocalFileTime(in, out);  }

This may be done with all lines throwing this kind of warning.

I don't know if this is the best solution, but it is the one that worked for me.

Change History (1)

comment:1 by Ion Gaztañaga, 12 years ago

Resolution: invalid
Status: newclosed

In windows headers parameters are declared const and function is extern C so this should be reported to Boost.DateTime.

Note: See TracTickets for help on using tickets.