Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#5326 closed Bugs (wontfix)

several g++ warnings found when compile boost::interprocess examples

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

Description

Hi, When I compiled the examples on boost_1_46_1/doc/html/interprocess/synchronization_mechanisms.html, in windows 7 g++ mingw 4.5.2 generated the executable with the following warnings(though the program run correctly).

output of g++ mingw 4.5.2 in DevC++: Compiler: Default compiler Building Makefile: "C:\code\test\ipc2\dev\Makefile.win" Executing make... mingw32-make -f "C:\code\test\ipc2\dev\Makefile.win" all g++.exe -c ../ipc2.cpp -o ../ipc2.o -I"include" -I"F:/boost_1_46_1" -Wall -Wno-deprecated -DWIN32 -mthreads -march=i686 -fexceptions -std=gnu++0x -DNDEBUG -fexceptions -O2

In file included from F:/boost_1_46_1/boost/interprocess/errors.hpp:37:0,

from F:/boost_1_46_1/boost/interprocess/exceptions.hpp:20, from F:/boost_1_46_1/boost/interprocess/shared_memory_object.hpp:17, from ../ipc2.cpp:1:

F:/boost_1_46_1/boost/interprocess/detail/win32_api.hpp: In function 'bool boost::interprocess::winapi::get_wmi_class_attribute(std::wstring&, const wchar_t*, const wchar_t*)': F:/boost_1_46_1/boost/interprocess/detail/win32_api.hpp:1472:21: warning: unused variable 'co_initialize_end'

In file included from F:/boost_1_46_1/boost/date_time/microsec_time_clock.hpp:23:0,

from F:/boost_1_46_1/boost/date_time/posix_time/posix_time_types.hpp:11,

from F:/boost_1_46_1/boost/interprocess/detail/posix_time_types_wrk.hpp:23, from F:/boost_1_46_1/boost/interprocess/sync/scoped_lock.hpp:31, from ../ipc2.cpp:3:

F:/boost_1_46_1/boost/date_time/filetime_functions.hpp: At global scope: F:/boost_1_46_1/boost/date_time/filetime_functions.hpp:57:90: warning: declaration of 'void boost::date_time::winapi::GetSystemTimeAsFileTime(boost::date_time::winapi::FILETIME*)' with C language linkage F:/boost_1_46_1/boost/interprocess/detail/win32_api.hpp:798:49: warning: conflicts with previous declaration 'void boost::interprocess::winapi::GetSystemTimeAsFileTime(boost::interprocess::winapi::interprocess_filetime*)' F:/boost_1_46_1/boost/date_time/filetime_functions.hpp:58:122: warning: declaration of 'int boost::date_time::winapi::FileTimeToLocalFileTime(const boost::date_time::winapi::FILETIME*, boost::date_time::winapi::FILETIME*)' with C language linkage F:/boost_1_46_1/boost/interprocess/detail/win32_api.hpp:799:49: warning: conflicts with previous declaration 'int boost::interprocess::winapi::FileTimeToLocalFileTime(const boost::interprocess::winapi::interprocess_filetime*, const boost::interprocess::winapi::interprocess_filetime*)'

../ipc2.cpp: In function 'int main()': ../ipc2.cpp:18:10: warning: unused variable 'remover'

g++.exe ../ipc2.o -o "ipc2.exe" -L"lib" -L"F:/boost_1_46_1/stage/lib" -s -lole32 -loleaut32 -lboost_date_time-mgw45-mt-1_46_1 -s

Execution terminated

source file: #include <boost/interprocess/shared_memory_object.hpp> #include <boost/interprocess/mapped_region.hpp> #include <boost/interprocess/sync/scoped_lock.hpp> #include "doc_anonymous_mutex_shared_data.hpp" #include <iostream> #include <cstdio>

using namespace boost::interprocess;

int main () {

try {

Remove shared memory on destruction struct shm_remove {

~shm_remove(){ shared_memory_object::remove("MySharedMemory"); }

} remover;

Open the shared memory object. shared_memory_object shm

(open_only only create ,"MySharedMemory" name ,read_write read-write mode );

Map the whole shared memory in this process mapped_region region

(shm What to map ,read_write Map it as read-write );

Get the address of the mapped region void * addr = region.get_address();

Construct the shared structure in memory shared_memory_log * data = static_cast<shared_memory_log*>(addr);

Write some logs for(int i = 0; i < 100; ++i){

Lock the mutex scoped_lock<interprocess_mutex> lock(data->mutex); std::sprintf(data->items[(data->current_line++) % shared_memory_log::NumItems]

,"%s_%d", "process_a", i);

printf("%s\n",data->items[i]);

if(i == (shared_memory_log::NumItems-1))

data->end_b = true;

Mutex is released here

}

Wait until the other process ends while(1){

scoped_lock<interprocess_mutex> lock(data->mutex); if(data->end_a)

break;

}

}

catch(interprocess_exception &ex) {

std::cout << "ipc exception caught:" << ex.what() << std::endl; return 1;

} return 0;

}

Change History (2)

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

Resolution: wontfix
Status: newclosed

Fixed co_initialize_end warning in Boost 1.47. The other warnings can't be fixed without moving windows predeclarations to a common place for Boost.Interprocess and Boost.DateTime.

comment:2 by anonymous, 11 years ago

I found this report via Google as I am experiencing the same issue.

Is it possible to declare the variables with the attribute ((unused)) for GCC / MinGW ?

Note: See TracTickets for help on using tickets.