Sponsored Content
Top Forums Programming Dereferencing pointer to incomplete type Post 302416805 by jim mcnamara on Tuesday 27th of April 2010 07:59:52 PM
Old 04-27-2010
I was going to try to get you to code thru your problem, but there were several issues, not just the pointer problem. You HAVE to call pthread_wait in main() or the whole process will exit and the thread may or may not have ever executed Client(). So I just made a few changes and let it go with that.

I removed a bunch of intermediate variables, I left error checking up to you. Check return codes. Always.

Code:
#include<stdio.h>
#include<string.h>
#include<pthread.h>

void *Client(void *);

typedef
struct {
 	long int x;
	long int y;
	} coord_t;


int main()
{
  int rc=0;
  int *p=&rc;
  coord_t my_coord={0,0};
  pthread_t threadid;
  
  printf("enter the coordinates for i & j ");
  scanf("%ld %ld", &my_coord.x, &my_coord.y);
  rc = pthread_create(&threadid, NULL, Client, &my_coord);
  pthread_join(threadid, (void **)&p);
  return 0;
}

void *Client(void * threadarg)
{
	coord_t *p = (coord_t *) threadarg;
	
	printf("%ld ", p->x);
	printf("%ld\n", p->y);
	pthread_exit(0);
}

 

10 More Discussions You Might Find Interesting

1. Programming

Accesing structure member:Error:dereferencing pointer to incomplete type

$ gcc -Wall -Werror struct.c struct.c: In function `main': struct.c:18: error: dereferencing pointer to incomplete type $ cat struct.c #include <stdio.h> #include <stdlib.h> #include <string.h> /*Declaration of structure*/ struct human { char *first; char gender; int age; } man,... (3 Replies)
Discussion started by: amit4g
3 Replies

2. Programming

array type has incomplete element type

Dear colleagues, One of my friend have a problem with c code. While compiling a c program it displays a message like "array type has incomplete element type". Any body can provide a solution for it. Jaganadh.G (1 Reply)
Discussion started by: jaganadh
1 Replies

3. Programming

error: field has incomplete type

Hello there, Here is how it goes - I have written a small test driver as an exercise to "Linux Device Drivers" and as a preparation for writing a real, functional driver. For the sake of seeing how far I got it working (I already implemented the open(0, read(), write() and ioctl() calls) I... (4 Replies)
Discussion started by: boyanov
4 Replies

4. Programming

error: field `fatx_i' has incomplete type

I'm trying to compile a 2.4.26 kernel but I have to apply two patches to it. The patches are: linux-2.4.26-xbox.patch openMosix-2.4.26-1 This is the reason that it doesn't compile. There is only one error but I'm not familiar with C or C++(Unfortunately only Java and some lower-level... (2 Replies)
Discussion started by: lateralus01
2 Replies

5. Programming

pass a pointer-to-pointer, or return a pointer?

If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it: (1) one is to pass a pointer-to-pointer parameter, like: int my_malloc(int size, char **pmem) { *pmem=(char *)malloc(size); if(*pmem==NULL)... (11 Replies)
Discussion started by: aaronwong
11 Replies

6. UNIX for Dummies Questions & Answers

Build Error: error: dereferencing pointer to incomplete type

I'm getting the following Error: prepare_pcap.c: In function `prepare_pkts': prepare_pcap.c:127: error: dereferencing pointer to incomplete type prepare_pcap.c:138: error: dereferencing pointer to incomplete type ==================================== This is the part of the relevant... (8 Replies)
Discussion started by: katwala
8 Replies

7. Programming

gcc 4.3.2 accept sys call warrning incompatible pointer type

Hi all, this warning is driving me nuts. I use -pedantic with -Wall and -Werror so this needs to be fixed. BUILD: GNU-Linux-x86 Any ideas? struct sockaddr_in server_addr; int addr_len = sizeof (server_addr); fd = accept(link->socket_fd, (struct sockaddr_in *)... (2 Replies)
Discussion started by: personificator
2 Replies

8. Programming

Dereferencing pointer to a shared memory struct

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 I’m struggling accessing members in the struct from the pointer returned by shmat. Ultimately, I want to access members in the shared memory structure... (2 Replies)
Discussion started by: arette
2 Replies

9. Programming

Compilation Error: dereferencing pointer to incomplete type

I am getting a dereferencing pointer to incomplete type error when i compile the following code on lines highlighted in red. Can anyone help me in identifying what is wrong in the code? #include<stdio.h> #include<stdlib.h> typedef struct{ int info; struct node* link ; } node; void... (3 Replies)
Discussion started by: sreeharshasn
3 Replies

10. Programming

Warning: pointer type mismatch

Hi all, I'm new programming in C, so I had the next message in my code: Dual.c:88:20: warning: pointer type mismatch in conditional expression : &clientSa.sin6.sin6.sin6_addr, Any help would be great #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include... (1 Reply)
Discussion started by: godna
1 Replies
MooseX::Storage(3pm)					User Contributed Perl Documentation				      MooseX::Storage(3pm)

NAME
MooseX::Storage - A serialization framework for Moose classes VERSION
version 0.45 SYNOPSIS
package Point; use Moose; use MooseX::Storage; with Storage('format' => 'JSON', 'io' => 'File'); has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); 1; my $p = Point->new(x => 10, y => 10); ## methods to pack/unpack an ## object in perl data structures # pack the class into a hash $p->pack(); # { __CLASS__ => 'Point-0.01', x => 10, y => 10 } # unpack the hash into a class my $p2 = Point->unpack({ __CLASS__ => 'Point-0.01', x => 10, y => 10 }); ## methods to freeze/thaw into ## a specified serialization format ## (in this case JSON) # pack the class into a JSON string $p->freeze(); # { "__CLASS__" : "Point-0.01", "x" : 10, "y" : 10 } # unpack the JSON string into a class my $p2 = Point->thaw('{ "__CLASS__" : "Point-0.01", "x" : 10, "y" : 10 }'); ## methods to load/store a class ## on the file system $p->store('my_point.json'); my $p2 = Point->load('my_point.json'); DESCRIPTION
MooseX::Storage is a serialization framework for Moose, it provides a very flexible and highly pluggable way to serialize Moose classes to a number of different formats and styles. Important Note This is still an early release of this module, so use with caution. It's outward facing serialization API should be considered stable, but I still reserve the right to make tweaks if I need too. Anything beyond the basic pack/unpack, freeze/thaw and load/store should not be relied on. Levels of Serialization There are 3 levels to the serialization, each of which builds upon the other and each of which can be customized to the specific needs of your class. base The first (base) level is "pack" and "unpack". In this level the class is serialized into a Perl HASH reference, it is tagged with the class name and each instance attribute is stored. Very simple. This level is not optional, it is the bare minimum that MooseX::Storage provides and all other levels build on top of this. See MooseX::Storage::Basic for the fundamental implementation and options to "pack" and "unpack" format The second (format) level is "freeze" and "thaw". In this level the output of "pack" is sent to "freeze" or the output of "thaw" is sent to "unpack". This levels primary role is to convert to and from the specific serialization format and Perl land. This level is optional, if you don't want/need it, you don't have to have it. You can just use "pack"/"unpack" instead. io The third (io) level is "load" and "store". In this level we are reading and writing data to file/network/database/etc. This level is also optional, in most cases it does require a "format" role to also be used, the exception being the "StorableFile" role. Behaviour modifiers The serialization behaviour can be changed by supplying "traits". This can be done as follows: use MooseX::Storage; with Storage( traits => [Trait1, Trait2,...] ); The following traits are currently bundled with "MooseX::Storage": OnlyWhenBuilt Only attributes that have been built (i.e., where the predicate returns 'true') will be serialized. This avoids any potentially expensive computations. See MooseX::Storage::Traits::OnlyWhenBuilt for details. How we serialize There are always limits to any serialization framework, there are just some things which are really difficult to serialize properly and some things which cannot be serialized at all. What can be serialized? Currently only numbers, string, ARRAY refs, HASH refs and other MooseX::Storage enabled objects are supported. With Array and Hash references the first level down is inspected and any objects found are serialized/deserialized for you. We do not do this recursively by default, however this feature may become an option eventually. The specific serialize/deserialize routine is determined by the Moose type constraint a specific attribute has. In most cases subtypes of the supported types are handled correctly, and there is a facility for adding handlers for custom types as well. This will get documented eventually, but it is currently still in development. What can not be serialized? We do not support CODE references yet, but this support might be added in using B::Deparse or some other deep magic. Scalar refs are not supported, mostly because there is no way to know if the value being referenced will be there when the object is inflated. I highly doubt will be ever support this in a general sense, but it would be possible to add this yourself for a small specific case. Circular references are specifically disallowed, however if you break the cycles yourself then re-assemble them later you can get around this. The reason we disallow circular refs is because they are not always supported in all formats we use, and they tend to be very tricky to do for all possible cases. It is almost always something you want to have tight control over anyway. CAVEAT
This is not a persistence framework; changes to your object after you load or store it will not be reflected in the stored class. EXPORTS
Storage (%options) This module will export the "Storage" method and can be used to load a specific set of MooseX::Storage roles to implement a specific combination of features. It is meant to make things easier, but it is by no means the only way. You can still compose your roles by hand if you like. By default, options are assumed to be short forms. For example, this: Storage(format => 'JSON'); ...will result in looking for MooseX::Storage::Format::JSON. To use a role that is not under the default namespace prefix, start with an equal sign: Storage(format => '=My::Private::JSONFormat'); To use a parameterized role (for which, see MooseX::Role::Parameterized) you can pass an arrayref of the role name (in short or long form, as above) and its parameters: Storage(format => [ JSONpm => { json_opts => { pretty => 1 } } ]); METHODS
import Introspection meta TODO
This module needs docs and probably a Cookbook of some kind as well. This is an early release, so that is my excuse for now :) For the time being, please read the tests and feel free to email me if you have any questions. This module can also be discussed on IRC in the #moose channel on irc.perl.org. BUGS
All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. AUTHORS
o Chris Prather <chris.prather@iinteractive.com> o Stevan Little <stevan.little@iinteractive.com> o XXXX XXX'XX (Yuval Kogman) <nothingmuch@woobling.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2007 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. CONTRIBUTORS
o Chris Prather <chris@prather.org> o Cory Watson <gphat@Crankwizzah.local> o Dagfinn Ilmari Mannsaaker <ilmari@ilmari.org> o David Golden <dagolden@cpan.org> o David Steinbrunner <dsteinbrunner@pobox.com> o Florian Ragwitz <rafl@debian.org> o Johannes Plunien <plu@pqpq.de> o Jonathan Rockway <jon@jrock.us> o Jonathan Yu <frequency@cpan.org> o Jos Boumans <jos@dwim.org> o Karen Etheridge <ether@cpan.org> o Ricardo Signes <rjbs@cpan.org> o Robert Boone <robo4288@gmail.com> o Shawn M Moore <sartak@gmail.com> o Tomas Doran <bobtfish@bobtfish.net> o Yuval Kogman <nothingmuch@woobling.org> perl v5.18.2 2013-12-21 MooseX::Storage(3pm)
All times are GMT -4. The time now is 09:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy