i've created dll and implemented shared memory that every connected process can use. My problem is that i can't change anything in object, which is stored in the memory.
my class :
class MyClass
{
public:
MyClass();
void test();
int counter;
};
void MyClass::test() {
MessageBoxA(NULL, "test", "test", 0x0000000L);
counter++;
}
memSegment = new managed_shared_memory(create_only, SHARED_MEMORY_NAME, 4096);
offset_mt = memSegment->construct<MyClass>("MyClass myClass")();
And then in an exported function i call
offset_mt.get()->test();
Im calling this from Java using JNA and result is a memory error (Invalid memory access). However, if I delete 'counter++' from test method, everything works fine - message box appears. Is there a limitation that I cant modify objects inside mapped memory or is this done the other way?
I have a data buffer project in Windows 7 x64 embedded OS (using Visual Studio 2008), that would work simply like that:
One writer application will send data (no network protocols, just procedure call on the same machine) to my app like 20 packages per second, each data packages will be approximately 3 MB size and comes with a timestamp tag.
My application will store each data item for 100 minutes and then remove. (So I can calculate the total size from beginnig no need for dynamic allocation etc...)
Meanwhile there will be up to 5 reader applications which will query data from my app via Timestamp tag and retreive data (no updates or deletitions on data by reader apps).
So since the data in my buffer app can grow over 50GB I don't think that shared memory is going to work for my case.
I'm thinking about using Boost Memory Mapped Files or Windows API Memory Mapped Files.
So theoratically I will crate a fixed size File on harddisk (lets say 50GB) and then map some portion to RAM write the data to this portion, if the reader applications wants to use the data which is mapped currently on memory, then they will use directly, otherwise they will map some other potion of the file to their address spaces and use from there...
My problem is I haven't use Map File concept at all and I'm not a C++ developer so I'm not very familiar with the language fundementals. I've searched tutorials of boost and msdn for windows as well but there is not too much code example.
So I don't know how to map some portion of the data to memory and manage it, also how to search data in file or memory according to the timestamp tag. Yes there are codes for creating files and mapping the whole file to memory but none for dividing it into regions, aligning or padding the data which I need for my case.
Worked with genetic algorithms. im solving travelling salesman problem with genetic algorithm and unfortunately stuck at crossover im using partially mapped cross over. i have tried coding it but it some time does not gives valid tour. Looking for building its logic.
I have found that when I dump a C++ object from memory to a file - it seems that there is a misplacement of the last Virtual-Function-Table pointer - in that appears at the beginning. The result is that the gdump information based on this object dump (using green hills) is incorrect. I copied the contents of the gdump information below. The executable is compiled in linux.
Basically MEIO::CameraStatus contains an item that relates to its parent class (line 188). Then it has 18 items that are all Diagnostics::EventsCounter items. Now for each Diagnostics::EventsCounter item there is a Virtual-Function-Table Info Pointer as its last item. All is fine and good except that the last item of MEIO::CameraStatus which is _selfReset is missing its last item of 4 bytes (which is the Virtual-Function-Table Info Pointer ). On the other hand - right before the first Diagnostics::EventsCounter item ("_vidErrors") - there is an extra 4 bytes which happens to be the Virtual-Function-Table Info Pointer. As I said the gdump information file does not see this.
Why the object memory "moves" the last Virtual-Function-Table Info Pointer to the beginning (right before _vidErrors) and is there a way to "fix" this?
/////////////////////////////////////////////////////////////////////////// "MEIO::CameraStatus" val:0x000002f0 ind208,-1) Struct-Begin Info 188: "" offset 0, Parent-Class Private Info C++ Struct ref = 114 189: "_vidErrors" offset 160, Member Info C++ Struct ref = 128 190: "_vdiErrors" offset 480, Member Info C++ Struct ref = 128
Try to implement overloading << operator. If I done it void then everything work fine (see comment out) if I make it class of ostream& then the operator return to me some memory address.
Code: #ifndef Point_HPP // anti multiply including gates #define Point_HPP #include <sstream> class Point { private:// declaration of private data members double x;// X coordinate double y;// Y coordinate
A C++ container type called std::map is used to store elements that are formed by a combination of key value and mapped value. How do you iterate through this container and find the value mapped to a specific key?
Not much to go wrong here, right? As long as I have the correct permission to write in the folders and the folders exists, this would normally go smooth. But for some reason it only copies the file. The source file still exists, but it has successfully copied the file to the destination folder. No exceptions has been thrown or anything... but the file still exists in the source directory
I then changed the code to the following:
System.IO.File.Copy("Y:TempFile.txt", "Y:Temp2File.txt"); System.IO.File.Delete("Y:TempFile.txt"); Console.WriteLine("See mommy, no Exceptions");
As expected the file copies correctly, but the delete command is completely ignored. The file is not deleted, but the Console.WriteLine command is called
I'm running the application as the logged in user. The user has permission to delete the file. If I try from Windows Explorer, the file is correctly deleted. Unfortunately my application refuses to delete the file and even worse, it will not even throw an Exception.
I have in my main(), a function that creates my arg object using boost/program_options.hpp i want to pass this object to another function using templates like this:
Code: template <typename Targ> void Count(Targ & arg){ MyObj<string> QueryTab(arg["input-file"].as<string>()); //line number is 352 ... }
However I get an error:
Code: ../include/Filter.hpp: In member function ‘void Count(Targ&)’: ../include/Filter.hpp:352:40: error: expected primary-expression before ‘>’ token ../include/Filter.hpp:352:42: error: expected primary-expression before ‘)’ token ... obviously it does not recognize my intention, what did I do wrong?
I have one problem deleting a file with boost. The file is opened in another application and cannot be deleted. I am supposed to received an exception error but I don't get it.
I have put a breakpoint inside the catch part but it does not come to this point. Instead, the the output window of visual studio, I got these lines:
First-chance exception at 0x00007FFD2E575A88 in site_server.exe: Microsoft C++ exception: boost::filesystem::filesystem_error at memory location 0x00000070F8E3E920. Unhandled exception at at 0x00007FFD2E575A88 in site_server.exe: Microsoft C++ exception: boost::filesystem::filesystem_error at memory location 0x00000070F8E3E920.
So I need to use boost/regex for regular expressions. someone told me that it needs to be built. the first problem is boost doesn't tell you how to build it and the second is i did sudo apt-get install libboost something. I don't remember the exact name of the package. it installed but i dont know how i would build it when its installed.
I have been using a Boost NonCopyable library in Microsoft Visual Studio 2013.
What I have is the following error message:
Error1error C2280: 'boost::noncopyable_::noncopyable::noncopyable(const boost::noncopyable_::noncopyable &)' : attempting to reference a deleted functionc:usersjohndocumentsvisual studio 2013projectsdonttreaddonttreaddonttread.cpp181DontTread
Now what I want to rectify the error is to throw an exception, so that the program can compile smoothly.
I have written a program that uses boost in visual studio 2012. The only boost library I used is filesystem by doing.
1)Properties->Linker->General and adding the path or the .lib to the additional dependencies. The libraries, link at compile time.However when i move the exe to a different computer, it doesn't work. Therefore the libraries were dynamically not statically linked. So my question is how do I statically link the filesystem library, so that i can include boost/filesystem.hpp in visual studio 2012?
I am using boost matrix for generating matrices used for filters. I wan to assign a pointer to these matrices so i can call them out of the function. but i am not able to understand where i am failing. the example code is here.
I think all are installed properly. I am trying to use Xcode to include the library of boost:thread.My code links to the header file properly with " #include "boost/thread.hpp"" commented, as seen from the following:
However, it could not link properly to boost-thread if "#include "boost/thread.hpp"" is un-commented.
Error page is shown as:
I have linked the dynamic library libboost_thread.a and libboost_thread.dylib and included /usr/local/include into header search path and /usr/local/lib into library search path.
I have the following code which is based of the tut3.cpp example at: [URL] ....
However, I'm not entirely sure how to retrieve the full file path which I'd like to use to get the file size. So essentially the aim is to go through a directory and list all the file sizes.
Code: if (exists(p)) { if (is_directory(p)) { cout << p << " is a directory containing: "; copy(directory_iterator(p), directory_iterator(), // directory_iterator::value_type
I wanna create mesh Array using boost elements, that will be do the same that code below, but can accept numbers of double. Any boost array that give me needed functionality. It will be great that advised element has the same argument list. I mean
// [base,stride,bound) // [0,2,4)
Or may be there are any opportunity modify this boost::multi_array_types::index_range in order do make it accept double...
1>------ Build started: Project: HP_A.1_d_, Configuration: Debug Win32 ------ 1> Main.cpp 1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(15): warning C4244: 'argument' : conversion from 'double' to '__w64 int', possible loss of data 1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(15): warning C4244: 'argument' : conversion from 'double' to '__w64 int', possible loss of data 1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(18): warning C4244: 'argument' : conversion from 'double' to 'unsigned int', possible loss of data 1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(20): warning C4244: 'argument' : conversion from 'double' to 'unsigned int', possible loss of data 1>c:all myс++ha level 9solutionlevel 9hp_a.1_d_main.cpp(20): warning C4244: 'argument' : conversion from 'double' to 'unsigned int', possible loss of data 1> HP_A.1_d_.vcxproj -> C:all myс++HA level 9SolutionLevel 9DebugHP_A.1_d_.exe ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
I have been working with and trying to understand Boost for random number generating. I've come to understand that what I want is now in the C++11 standard, but I've stuck with Boost.
What I have done is create a simple main.cpp that generated random numbers successfully. From there I wanted to create a more optimal system by separating out the random code portion to a class that can be instantiated and called on demand. My problem now is that when I call the random routine of the class I just get one number no matter how many times it's called.
I know that rapid seeding is an issue so I put the seed function of the random portion in the class's constructer so that it is only called once on the creation of a class. I also tried making it a static member, but I haven't had success with that yet either. For now though, I would simply like to get successive random values upon calling the class's random function.
class header Code: #ifndef roomGen_hpp_ #define roomGen_hpp_ #include"boost/random.hpp" #include"main.hpp" class roomGen { private: boost::mt19937rngDimensions;
[code].....
The main.hpp file only contains a couple of struct definitions. In main I call the class with Code: randomRooms.push_back(randRooms.createRoom()); to get back a struct with random values and push it into a vector.
I'm unsure what I'm doing wrong here to only get back a single non random number from successive calls. I have tried moving the variable creation lines from roomGen::createRoom() to the private area of the class definition, but that causes me to get a slew of undefined errors so I had to settle on putting those declarations inside the function.
I've been studying metaprogramming and reviewing many documents and code regarding boost files. What I've been trying to understand and accomplish is creating various types using typedef, template and struct, similar to that of the boost files themselves, to create comparators. Ultimately, I want to be able to create a type that has sub-properties which can be further compared and classified.
Where other variables can be represented based off this i,j,k standard and written in a more direct vector form.
And so on...
What I essentially would like to do is have x,y,z variables act as standards for an i,j,k system that classify arbitrary variables of the coordinate type: Is the arbitrary variable i, j, or k? Is it defined as an int or float type?
Where arguments such as sum_y = var1 + var2; are valid, provided: sum_y is outputted as 6j, and var1 and var2 are 2j and 4j, respectively.
I am trying to compare strings (char*) using strcmp but I am having a hard time doing it with boost::bind. It compiles but it crashes when I run it.
I have a std::vector<boost::shared_ptr<DeviceInfo>> cMonitoredDevices and one cCurrentDevices. I used a typedef DeviceContainer for std::vector<boost::shared_ptr<DeviceInfo>>.
DeviceInfo is a simply struct that contains a char[128] Name (and other fields not important for this issue) that I want to use to compare.
So I am trying to find the DeviceInfo (based on Name) that are in cMonitoredDevice but not in cCurrentDevices. My problem is retrieving the Name value for the strcmp. Here is what I have so far
I have been trying to compile a static version of the boost libraries, however when I try to launch the program it says fatal error LNK1104: cannot open file 'libboost_serialization-vc100-mt-s-1_53.lib'
I have checked in the boost/stage/lib folder and that file is not there. I compiled boost with b2 link=static yet the file still isn't there.