Programming :: Void Pointer - Open Plugin And Run It
Feb 5, 2011
I have a problem with correctly using a void pointer. I am writing a system that can open plugins and run them, and so far everything is going fine: I have a struct with some variables in, some function pointers, and I've written a small library to handle these correctly to communicate with the plugin. My challenge is that I need to put a pointer (let's call it "context") into this struct. The type is not important to the main body of code, and it is not ever used except by the plugin. The plugin will malloc some space for itself, and this *context will then point to whatever malloc returned. context is the address to a struct that I typedeffed to "ctxt".
Here is the first struct I mentioned:
Code:
typedef struct slave {
int val1;
int val2;
int (*entry)(struct slave*, int a, int b);
void *context;
} target;
Here are some snippets from the plugin:
Code:
typedef struct context {
int a;
int b;
} ctxt;
(*target).context = malloc(sizeof(struct ctxt));
So that (*target).*(ctxt)*context.a should refer to the int a in struct context.
But the error that the compiler gives me is a syntax one:
"expected identifier before '*' token"
Is my logic correct? Is my C correct?
View 11 Replies
ADVERTISEMENT
Mar 20, 2010
So far I have this:
Code:
int mm_init (mm_t *MM, int hm, int sz) {
int i;
[code]...
View 4 Replies
View Related
Sep 29, 2010
I have been trying to get a void pointer cast to work and I seem to have some problems. My code compiles, but when I execute it gives back garbage data. I'm not sure what I'm doing wrong.
Code:
int main()
{
[code]....
View 7 Replies
View Related
Feb 8, 2011
I have written a small character driver, in the cleanup module at the line
int a=unregister_chrdev(Major,DEVICE_NAME);
I am getting the following error
error: void value not ignored as it ought to be
If the value return by unregister_chrdev() function is not stored in any variable it is working fine...
View 2 Replies
View Related
Aug 27, 2010
I was going through a file known as linux-2.6.34/kernel/timer.c and found following code.
static inline void
timer_set_base(struct timer_list *timer, struct tvec_base *new_base)
{
timer->base = (struct tvec_base *)((unsigned long)(new_base) |
tbase_get_deferrable(timer->base));
}
I want to understand what is it doing. What is the meaning of static inline in above? I searched and came across
[Code]...
View 4 Replies
View Related
Jun 27, 2009
I have been googling trying to fix this ... basicly I have a (int **) variable, and when I try to pass a (int) value to a specific position, I have seg.fault.Resuming what I have is:
int ** p;
p[0][0] = 1; //segmentation fault
View 7 Replies
View Related
Mar 14, 2010
So, DnD is cool - and in Java, it works. Just set the component where the drag starts to allow that:
Quote: tblMain.setDragEnabled(true);
and - yes - the rest pretty much runs itself. I have a JTextField that happily takes the drop from the JTable (be it the whole row - I'm not there yet, still working on that)...but does not raise any events. I'd like the JTextField to raise an event:
- cleaning up the received data, now it gets the raw stuff, and I need an ID from that string
- starting up another void() with the received ID
I read the tutorials but - for blisters - cannot see the "light", please shed some (light, that is)
View 1 Replies
View Related
Apr 24, 2011
Is it possible to check if a pointer is deleted in C++ (using GDB)? For example:
Code:
a = new Thing();
b = a;
delete a;
// If all I have is the variable "b", how can I tell if it was deleted?
View 14 Replies
View Related
Jul 6, 2010
I'm trying to write a simple program that lists a menu and then asks you for your decision, and you can answer with a number or the name. However, I don't know how to add the second options (name).
View 14 Replies
View Related
May 19, 2011
#!/bin/bash
sed -n 8p file.txt
returns the 8th line to the StdOut.
If I assign the value to the variable line = $(sed -n 8p file.txt)
and now print it out with echo
echo $line
the line would be printed.
But what if the file has only 4 lines. What value would be assigned to the variable line?
I want to know that because I want to only print it if the value is "something", that is not null.
In Java for example I would do it like this...
String line = "";
line = reader.readLine(); // or anything else..
if(line!=null){
System.out.println(line);
}
How would I check if the value is not "null"(I don't know if bash knows null)
View 13 Replies
View Related
Aug 23, 2009
Code:
#include <stdio.h>
int main ()
[code]...
View 7 Replies
View Related
Jul 26, 2010
Whats the practical diffrens between these declarations in c?
char *a_str = "hello";
char a_str[] = "hello";
View 4 Replies
View Related
Jul 12, 2010
i was trying to access the address of the character pointer it gives me the values stored in the variable.
Code: #include<iostream>
using namespace std;
int main()
{
char *i;
[Code]....
why is my code not giving the address of the variable i when it is a character pointer.
View 2 Replies
View Related
Jul 15, 2010
I'm getting some information about C language and this session of a C book (follow the above link) is using a bad example for me. When I'm trying this example of function returning a pointer, my compiler is stating a warning that I return a pointer to a local variable. I realized that it is error prone after all this variable may be override before the function has done his execution. And the author is fooling me saying that this example is "perfectly safe". I'm wrong? There is something that I don't got yet? Sorry but this site is preventing me to post the link of book cause I'm a newbie, so a need the hack it. Just strip out the question signs:
{LINK}
?w?w?w
?cs.cf.ac.uk?
[code]....
View 6 Replies
View Related
Dec 20, 2010
I want to assign an address location to a pointer and wanted to display the value at that memory location.I wrote a small program for this and it is like this : (i am using gcc 4.4 compiler)
# include "stdio.h"
int main()
{
unsigned int *a;
a=(unsigned int *)0x3f8;
printf("%u",*a);
return 0;
}
But it is giving Segmentation fault
View 14 Replies
View Related
Mar 10, 2009
i am trying to find the size of an array, not by using the array as a parameter to "sizeof", but by using a pointer -pointing to the array- as a parameter. How do i do this?I use a 32-bit PC.Here's:
Code:
#include <string>
#include <iostream>
[code]...
View 2 Replies
View Related
Dec 8, 2010
This is one of the strangest problems I've run into while programming. Maybe there's just something wrong with my version of gcc or something.
The main problem comes at this point in the code:
Code:
po = makePoFromScorbotXYZPR(X, Y, Z, P, R);
h = makeHB2GFromPo(po);
printf("%le", *h[1][0]); //##################################### Here it has the right value
printf("%s", "
[Code].....
View 2 Replies
View Related
Sep 29, 2010
I have got following code from a book:
Code:
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <stdlib.h>
#define PORTNUMBER 12345
[Code]...
View 6 Replies
View Related
Feb 28, 2010
From "man gcc"
-Wno-int-to-pointer-cast (C and Objective-C only)
Suppress warnings from casts to pointer type of an integer of a different size.
[code]...
View 3 Replies
View Related
Feb 15, 2009
How could i create a script that will move the mouse pointer around the screen.i'm thinking i need the Xlib modules (which i have installed) but don't know how to implement them
View 5 Replies
View Related
Oct 18, 2010
How do I get the page pointer from a physical address?
View 1 Replies
View Related
Feb 5, 2011
I have what should be a relatively simple program (fadec.c) that maps a struct from an included header file (fadec.h) to a shared memory region, but Im struggling accessing members in the struct from the pointer returned by shmat. Ultimately, I want to access members in the shared memory structure with a globally declared version of the struct, shm__. Not only do I not know how to accomplish that, but I cant even seem to access members of the shared struct directly from the pointer itself (compiler complains about dereferencing pointer to incomplete type). Im at a loss and could use another set of eyes if you guys dont mind taking a gander:
Compile Errors:
tony-pc:/cygdrive/p/test> cc -o fadec fadec.c
fadec.c: In function 'main':
fadec.c:30: error: dereferencing pointer to incomplete type
fadec.c:31: error: dereferencing pointer to incomplete type
[Code]...
View 1 Replies
View Related
Mar 30, 2011
I'm venturing into the world of OpenGL, but in the process of writing my graphics library I ran into a problem... My code is:
Code:
#include <stdio.h>
#include <stdlib.h>
[code]...
View 5 Replies
View Related
Jan 21, 2011
Say, i have an imaginary std library function, which I want to call.
Code:
void std_lib_func(ObjectType *param);
Now in my c++ program, I have a main() function, and I will like to call a customized function (which will in turn call the std lib function) from the main function, as below:
Code:
int main()
{
ObjectType *aobj;
customized_func(aobj);
}
[Code]...
I tried the below but get an error that the std lib function is expecting a ObjectType* param, not aobj. How should I work this out.
Code:
void customized_func(ObjectType aobj)
View 4 Replies
View Related
May 13, 2009
Please look at the comments
Code:
/*
* TEST CASE TO CHECK DIFFERENCES BETWEEN STRING AS
[code]...
View 14 Replies
View Related
Aug 5, 2010
hey dude error in gnu c pointer
I am using Red Hat Enterprise Linux 5.0.
#include <stdio.h>
#include <stdlib.h>
int main()
{
char * cp = NULL;
[Code].....
View 4 Replies
View Related
Feb 8, 2011
A friend working in HPC environments commented me that he had an issue regarding the use of the malloc() function.What issue?He told me that he has had cases in where malloc() instead of returning a NULL pointer on failure, simply didn't change the original value of the pointer it was trying to use for allocation, thus forcing him to initialize pointers to be allocated with malloc() to NULL, so that he could be sure that if malloc() fails, a test for NULL would make sense.
View 12 Replies
View Related
Feb 9, 2011
I want that I click with the mouse on the video, it paused.I notice that there is "BaconVideoWidget" which I guess is the video rendering widget but it don't have signal named "clicked":
Code:
vd = totem_object.get_video_widget()
vd.connect("clicked", vd.hide)
[code]....
View 3 Replies
View Related
Oct 8, 2010
I can not seem to find a pdf viewer browser plugin other than the actual craprobat plugin from Adobe. The default Ubuntu install comes with a perfectly good open source stand alone pdf viewer, but this means that the browser has to save it to your download directory then run the external viewer, and eventually your download directory is all cluttered up. I would much rather just view the pdf in the browser.Is there no open source browser plugin?
View 1 Replies
View Related
May 15, 2011
I am playing around with a new chat program and I have errors that I can not figure out. Here is what I am getting.
parse.c:1638: error: dereferencing pointer to incomplete type
parse.c:1638: error: dereferencing pointer to incomplete type
parse.c:1638: error: dereferencing pointer to incomplete type
here is the code:
if (scan->jail_timeout == 0 && scan->location == prison)
{
command_type |= HIGHLIGHT;
tell_player(scan, " After serving your sentence you are flung out"
[code]....
View 6 Replies
View Related