C++ :: Shared Pointer Dropping?

Sep 19, 2014

Is their a way to completely drop a shared_ptr. Then it will delete the memory and NULL all pointers linking to it?

View 4 Replies


ADVERTISEMENT

Visual C++ :: Dragging And Dropping Functionality In Windows 8 Environment

Jul 14, 2014

i have developed an application in which i have icons in left side pane of application which can be dragged and dropped in client screen. Application is working fine with all the resolution except 1920x1080.

when setting the resolution to 1920x1080 while dragging icons to client area, icon is not attach to mouse pointer. instead there is a gap between the mouse pointer and the icon. i wrote code to identify the screen resolution but it does not seem to recognize 1920x1080 resolution. below code is giving incorrect resolution for 1920x1080 setting.

RECT actualDesktop;
GetClientRect(GetDesktopWindow(),&actualDesktop);

value of 'actualDesktop' variable is {top=0 bottom=783 left=0 right=1536} which is incorrect. according to current resolution size value should be {top=0 bottom=1080 left=0 right=1920}. Due to this, all the icons while dragging are adjusting according to incorrect resolution setting.

how to identify the issue and if there is any limitation with respect to screen resolution in VC++ 6.0 with windows 8 environment.

I am getting same issue when compiling in VS2012 in windows 8. Code does not seem to recognize 1920x1080 resolution setting and downgrading my application look and feel by setting it to lower resolution.

View 1 Replies View Related

C# :: Graphic User Interface - Dragging And Dropping Controls In Form

Mar 5, 2014

is there a difference when creating a graphic user interface dragging and dropping controls in the form and coding on source code, difference in a sense that the code will appear differently if the control is dragged then the code appears automatically on the source code as compared to typing it on source code?

View 2 Replies View Related

C++ :: Shared Memory Between Processes

Apr 13, 2014

Say now I have a dll, loaded and run by a 32bit program. One of the things that I access from the program in the dll are several 1024x1024 int buffers. However I would like to put some data into those buffers from a external process. And I would like a separate thread in that external process for each buffer. Is there any way I can make that memory space accessible to the external process so I can use my own multi threaded memory transfers to pass that data over provided I ensure that the original process doesn't try to do anything with that data? And I would like to do this without resorting to the Read/WriteProcessMemory functions which are not threadsafe. In short, I want to set up direct memory access between the 2 programs without creating any intermediate shared memory buffers ie I want to set permissions for an existing memory space. Is this possible?

View 1 Replies View Related

C++ :: Multithreading - How To Modify Shared Object

Aug 24, 2014

class MyOwner {
...
int m_count;
bool b_locked;
};

[Code] ....

I am using an API where I create many MyObjects on the heap, and the API uses a separate thread to send messages to each object. Each MyObject contains a pointer to MyOwner.

Suppose I want to keep a count of all messages received in all MyObjects: How can I do this in a thread safe way?

I am assuming that the code I have written above will not be safe--at the very least it seems that it would potentially miss message counts when it was locked--not the worse case scenario for me. I am most concerned about not causing the application to crash.

View 5 Replies View Related

C++ :: Moving Objects To Shared Memory

Feb 9, 2013

I am not so experianced with c++ myself, but I need to evaluate if a certain idea might work.

I am working with a system for automation purposes that is running on a realtime OS in parallel to windows. Windows and the RTOS exchange data via shared memory. The application in the RTOS is compiled in C++. Now I would like to be able to influence the some data manipulation tasks in the RTOS application without changing the code of the RTOS application. So a concept like calling a dll.

My idea was to create a class with virtual methods in the RTOS application. The objects that are used should then be created on the Windows side with the same class prototype, but specific implementation of the virtual methods. The objects should then be moved to the shared memory, where they are used by the RTOS application.

Is something like this possible or am I completly on the wrong path?

View 4 Replies View Related

C++ :: Cannot Open Shared Object File

Nov 11, 2013

i'm writing a lexer, and i want to use boost::regex for it. im sure im using it right (just in case though)

while(!this->Source.empty())
{
if(regex_search(Start, End, Match, regex(""[^"]*""), Flags))

[code].....

someone told me to download the latest source and build that so i did, by unzipping it, cding to the source, running ./bootstrap.sh, ./b2, and finally ./b2 install. when i compile i get no errors but when i run it i get ./jade: error while loading shared libraries: libboost_regex.so.1.55.0: cannot open shared object file: No such file or directory

View 6 Replies View Related

C++ :: File Handling Vs Shared Memory?

May 27, 2014

In interprocess communication(IPC) when processe have to share data among each other,why cant they all connect to one single file and share data with basic file handling functions such as read and write?

Why do we need

shared memory(shmget shmat(),shmdt()..etc)
and
mapped memory(mmap(),munmap()..etc)

concepts?

View 3 Replies View Related

C :: How To Store Array Of Structure At Shared Memory

Jan 16, 2014

I have one requirement to store an array of structure at shared memory. Also the shared memory should have one counter to store number of elements in the array.

I tried to look at some placed but didn't find anything relevant.

So my first question, is it possible that we can store two things on same shared memory. And second if not then how to achieve the same?

View 5 Replies View Related

C :: Initialize 1D Or 2D Array In Shared Memory (POSIX)

Dec 8, 2014

I am trying to initialize a 2D char array of strings into POSIX shared memory to be shared between 3 other processes. There are plenty of tutorials on how to use a pointer to share a single string or an integer between processes, but I could find no examples on how to initialize 1D or 2D arrays using mmap(). I have posted what I have so far below. It is the first program, which creates the shared memory object and initialize the array char files[20][2][100] with the value files[0][0][0] = ''. What is the proper method to initialize and share an array in C?

(program initializes shared memory object and array)

Code:
#include<fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <sys/mman.h>

int main (int argc, char *argv[]){

[Code] ......

View 5 Replies View Related

C :: Shared Memory / Cannot Read Last Element In A Struct

Jun 27, 2014

I have trouble reading the last element in a struct.I do get the correct value for the first two elements. In my example that is:

a = 11 and c = H
however I get:
b = 0
but I am expecting b=2

I got two files to handle this.The first one is writing data to memory -

Code:

#include <sys/shm.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
}

[code]....

why I cannot get correct value for the third element in my struct?In the second file where I'm reading from memory I allocate some space. Is this incorrect in some way? I'm running this on a Linux machine.

View 2 Replies View Related

C :: How To Apply Mutex Lock On Shared Memory

Jul 11, 2014

I was trying to put mutex lock on shared memory but my code is not working. What I want is that if some process is putting something on shared memory segment, other process should not be able to access that segment. For testing , I create a server program which put data in shared memory and client program which access the data.

To test it, I put break point after:

pthread_mutex_lock(&(init_lock));

But I see that client program was able to access shared memory.

Below is code:

Server: Code: pthread_mutex_t init_lock = PTHREAD_MUTEX_INITIALIZER;
main()
{
char c;

[Code].....

View 1 Replies View Related

C++ :: How To Create Pros And Cons Of Shared Libraries

Aug 18, 2014

I want to know:

1. Pros and cons of shared libraries
2. How to create them(any tutorial link or book will be good)
3. Compare static libraries to dynamic ones

View 1 Replies View Related

C++ :: Shared Library Throws Exception But Not Caught

Jan 10, 2013

A test program of mine loads a shared library (.so file). A function call in the shared library throws an exception that I am trying to catch in the main function of my test program. (I know that exception is being thrown for sure, I wrote the library to do that.)

However in the main program, the exception is not being caught. The flow of program goes past the catch block like no error has occurred. I am using g++ and I load the shared file using -l option. Only trying to load the program statically I got the following error:

/usr/bin/ld: cannot find -lmy-shared-library
collect2: ld returned 1 exit status

Why the exception is not getting caught.

View 9 Replies View Related

C++ :: Shared Library Export And Calling Convention?

Aug 13, 2013

I want to create a simple shared library that exports a simple C API, just like llvm-clang.

The library should be compilable with any compiler and be used by a variety of languages, again just like clang.

For visual studio that is:

Code:
extern "C" __declspec(dllexport) void __cdecl myfunc(int arg);

The __cdecl is the issue here: i cannot seem to find a compiler agnostic way of specifying the use of cdecl.

So i went to see how my favorite C API libraries (ie clang) handle it.

none of them specify a calling convention at all!

Code:
#define CINDEX_LINKAGE __declspec(dllexport)
CINDEX_LINKAGE void clang_disposeIndex(CXIndex index); //exported

how does that work? How does the compiler know to use __cdecl and how would i link to it dynamically without that knowledge?

View 1 Replies View Related

Visual C++ :: Command For List Out Shared Folder In MFC?

Apr 12, 2013

I need to list out all the shared folders(directory) in the system along with their path . i want a command or an api in MFC, for listing out the shared directories.

View 2 Replies View Related

C :: How To Create A Shared Library From Source Code In Autopy

Jan 22, 2013

I'm trying to find a C library for automating mouse clicks and keystrokes, something like the Python package AutoPy would be ideal.

Might have heard of Auto-it [URL] ...., which automates GUIs in Windows. Something like that would also be good, but my main OS is Linux.

I'm not sure whether it would be possible to create a shared library from the C source code in autopy.

View 4 Replies View Related

C/C++ :: Shared Memory Project Not Getting Accurate Count For Processes

Jan 30, 2014

I'm working on a project that is supposed to create 3 processes. Process 1 should count from 1 to 100,000. Process 2 from 1 to 200,000. Process 3 from 1 to 300,000. I've written the basic code of it but my processes aren't printing out very accurate numbers.

Here's my code:

/*ass1*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdlib.h>
#include <unistd.h>
/* change the key number */
#define SHMKEY ((key_t) 8450)
typedef struct

[code]....

View 4 Replies View Related

C++ :: Shared Memory To Make Objects Of Application Persistent?

Aug 18, 2014

I have a question concerning shared memory (in linux-environment). In our company we currently have an application that is restarted once in a while. There are multiple instances running of this application (on different physical machines), and all access the same centralized database. Because of IO and Network bottleneck the start gets very slow, and takes about 10 Minutes. Besides some new data, most of the data stays the same, so reading from the database again is quite redundant. An idea is to write all relevant object to a shared memory segment, when the application is shut down. A second dummy process attaches to the same shared memory (just so that some process is still attached). If the application is restarted, it is attached again to its shared memory, and reads it to its own adress range again. There might occur a difference regarding the data so it might me necessary to load some new data afterwards, but that is different problem.

The current idea is to serialize all Objects (could be about 1-2 Gigabyte) with Apache Thrift, and write them into shared memory. With Thrift the data is more or less ordered, so creating the objects anew is possibly easier (not sure here).

My Question is:

- Does it even make sense to consider shared memory in this scenario. I've read a lot stuff about in the last few days, and for now I don't see big disadvantages (except if the application crashes, in this case I've to read from database again). On the other hand I don't know how to really implement this functionality (as I'm no experienced Developer)

- Should I aim for Boost::Interproces, considering even memory mappable files, or stay with the traditional shmat (and stuff..)?

- I guess 1-2 Gigabyte shared memory will be necessary. This amount is only needed in the gap between application shutdown and restart. Will the sheer amount of needed shared memory be a problem (all examples I found just used a few Bytes or Kilobytes)

View 9 Replies View Related

C :: Ubuntu Build - Test Program To See If Shared Library Properly Built

May 22, 2013

I have created a shared object in Ubuntu (libMYLIB.so). I am now trying to compile a simple test program (testmylib.c) to see if the shared object is properly built. I am getting an error that the build cannot find the shared object. My build command is:

gcc -lm -l /dir/mylib -lMYLIB.so -o testmylib testmylib.c

where /dir/mylib is where my source and libMYLIB.so reside.

What am I doing wrong?

View 9 Replies View Related

C/C++ :: Know That Data Written To Shared Memory Segment In Unix Is Stored Properly

Mar 8, 2012

I am trying to write a client/server application that takes input to an array of structures from the user,stores the data in a shared memory segment and then writes the same to a file when I close the application. How do I get started? And how do I ensure that the server stores the data correctly? Also, the server needs to be a concurrent server that accepts connections from multiple clients.

View 1 Replies View Related

C++ ::  typedef As Data Type For Specialized Template Function In Class From Shared Library

Jul 19, 2013

I have a class "Result" with a single template function Set(const std::string& arName, T& val) and a specialization of this function Set<Real>(const std::string& arName, Real& val) where Real is a typedef for double. The class is in a shared library and I use it in my main program. If I do result->Set<GLOBAL::Real>("U", 100.0); the wrong template function is called!

I check this by the output with std::cout.

Maybe it's a problem with the typedef.

If I link the object file of the Result class directly to my main program (no shared library), it works.

typedefs.hpp:
namespace GLOBAL {
typedef double Real;
} results.hpp
#include <iostream>

[Code] ....

View 3 Replies View Related

C++ :: Linked List Node Passed As Parameter / Argument Pointer To Pointer Notation

Jan 17, 2014

I was having problems changing the value of my head node I passed it as an argument as head which would be the address. The parameter was defined as struct node *head. like this

bool deleteNode(struct node *head, struct node *delptr)

I tried manipultaing pointer values to change head node value but it did not work. I saw some code online which used pointer to pointers(in code below) to change head node value it worked I dont fully understand why. Would like better understanding of why.

Would also like to know why the argument call needed &head instead of just head.

remove = deleteNode(&head,found); opposed to remove = deleteNode(head,found);

#include "stdafx.h"
#include<iostream>
struct node{

[Code].....

View 1 Replies View Related

C++ :: Shared Library Vs Static Library?

Jan 17, 2014

I've been reading about libraries; How to make them, how to use them, the different types of libraries, etc..

When using a shared library, does the program require that library to be installed on the computer after the program has been compiled into an .exe?

Ie.. if somebody downloaded a "Helloworld.exe" that I had compiled on my computer using a shared library (that wasn't part of a standard operating system), would they also need that shared library on their computer for the program to run without errors?

and for Static Libraries, when I compile a program using a static library, does it include in the final binary only the functions of the library that are actually used, or does the compiler add in the entire library?

View 8 Replies View Related

C++ :: Calling Defined Function Pointer From Another Pointer To Class Object?

Aug 19, 2014

I am attempting to implement function pointers and I am having a bit of a problem.

See the code example below; what I want to be able to do is call a function pointer from another pointer.

I'll admit that I may not be explaining this 100% correct but I am trying to implement the code inside the main function below.

class MainObject;
class SecondaryObject;
class SecondaryObject {
public:

[Code]....

View 10 Replies View Related

C :: Print Pascal Triangle And Stores It In A Pointer To A Pointer

Nov 27, 2013

I have to write a program to print pascals triangle and stores it in a pointer to a pointer , which I am not entirely sure how to do. I also have to write the file and read it, then create a binary file. Assignment is attached. I am not the best with programming and especially with pointers. I will post my code below.

Code:
#include <stdio.h>
#include <stdlib.h>
void writePascalTriangle(char *fileName, int heightOfTriangle, int **triangle) {
FILE *fp;
fp=fopen("writePascalTriangle.txt", "w");

[Code] ....

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved