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
wchar.h(3HEAD)							      Headers							    wchar.h(3HEAD)

NAME
wchar.h, wchar - wide-character handling SYNOPSIS
#include <wchar.h> DESCRIPTION
The <wchar.h> header defines the following types: wchar_t As described in <stddef.h>. wint_t An integer type capable of storing any valid value of wchar_t or WEOF. wctype_t A scalar type of a data object that can hold values which represent locale-specific character classification. mbstate_t An object type other than an array type that can hold the conversion state information necessary to convert between sequences of (possibly multi-byte) characters and wide characters. If a codeset is being used such that an mbstate_t needs to preserve more than two levels of reserved state, the results are unspecified. FILE As described in <stdio.h>. size_t As described in <stddef.h>. va_list As described in <stdarg.h>. The implementation supports one or more programming environments in which the width of wint_t is no greater than the width of type long. The names of these programming environments can be obtained using the confstr(3C) function or the getconf(1) utility. The <wchar.h> header defines the following macros: WCHAR_MAX The maximum value representable by an object of type wchar_t. WCHAR_MIN The minimum value representable by an object of type wchar_t. WEOF Constant expression of type wint_t that is returned by several WP functions to indicate end-of-file. NULL As described in <stddef.h>. The tag tm is declared as naming an incomplete structure type, the contents of which are described in the header <time.h>. Inclusion of the <wchar.h> header can make visible all symbols from the headers <ctype.h>, <string.h>, <stdarg.h>, <stddef.h>, <stdio.h>, <stdlib.h>, and <time.h>. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
getconf(1), btowc(3C), confstr(3C), fgetwc(3C), getws(3C), fputwc(3C), fputws(3C), fwide(3C), fwprintf(3C), fwscanf(3C), getwc(3C), getwchar(3C), iswalpha(3C), iswctype(3C), mbsinit(3C), mbrlen(3C), mbrtowc(3C), mbsrtowcs(3C), towlower(3C), towupper(3C), ungetwc(3C), vfwprintf(3C), wcrtomb(3C), wcsrtombs(3C), wcstring(3C), wcsstr(3C), wcstod(3C), wcscoll(3C), wcsftime(3C), wcstol(3C), wcstoul(3C), wcswidth(3C), wcsxfrm(3C), wctob(3C), wctype(3C), wcwidth(3C), wmemchr(3C), wmemcmp(3C), wmemcpy(3C), wmemmove(3C), wmemset(3C), stdarg(3EXT), stddef.h(3HEAD), stdio.h(3HEAD), stdlib.h(3HEAD), string.h(3HEAD), time.h(3HEAD), wctype.h(3HEAD), attributes(5), stan- dards(5) SunOS 5.10 10 Sep 2004 wchar.h(3HEAD)
All times are GMT -4. The time now is 08:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy