Gcc Error Invalid Type Argument Of 'unary
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads c error invalid type argument of unary '*' (have 'int') with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the invalid type argument of unary ‘*’ (have ‘int’) c Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: invalid type argument of unary '*' (have 'float') Sign up error: invalid type argument of ‘unary *’ (have ‘int’) up vote 20 down vote favorite 7 I have a C Program: #include
Invalid Type Argument Of Unary * C++
Can someone explain what this error means? c pointers share|improve this question edited Sep 30 '13 at 19:23 Eric Leschinski 46.7k23221190 asked Mar 28 '11 at 7:30 picstand 112127 add a comment| 4 Answers 4 active oldest votes up vote 14 down vote accepted Since c is holding the address of an integer pointer, its type should be int**: int **c; c = &a; The entire program becomes: #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more
Invalid Type Argument Of Unary '*' (have 'int') C++
about Stack Overflow the company Business Learn more about hiring developers or posting ads error invalid type argument of unary * have int c++ with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack invalid type argument of unary * have int malloc Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up invalid type argument of ‘unary *’ (have ‘int’) up vote -3 down http://stackoverflow.com/questions/5455866/error-invalid-type-argument-of-unary-have-int vote favorite im sorry for repeating the question, but i cant get my head around (what i think my problem is) pointers. Can someone please shed some light onto this for me? Ive trawled through heaps of stackoverflow questions, c tutoriols and its mostly confusing as each solution seems to contradict another - if i see my code being fixed im sure that will help me to fully understand http://stackoverflow.com/questions/23870814/invalid-type-argument-of-unary-have-int 1 #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business http://stackoverflow.com/questions/23773019/error-with-pointers-invalid-type-argument-of-unary Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation https://github.com/Intrepid/upc2c/issues/112 Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error with pointers. Invalid type argument of unary * up vote 0 down vote favorite #include "cdebug.h" #include "stdlib.h" int main() { char *cbloc invalid type = (char *)malloc(sizeof(char) * 40); memset(cbloc, 40, sizeof(char) * 40); DFORC(cbloc, 0, sizeof(char) * 40); system("PAUSE"); } Below is the header I wrote for debugging with pointers #ifndef _CDEBUG_H_ #define _CDEBUG_H_ #include "stdio.h" int counter; //Debugging functions written by skrillac //constants #define NEWLN() printf("\n"); #define DFORC(ptr, offset, len) for (counter = offset; counter < len+offset; counter++)printf("'%c', ", *ptr[counter]); #define DFORI(ptr, offset, len) for (counter = offset; counter < len+offset; counter++)printf("'%i', ", *ptr[counter]); #define DFORV(ptr, offset, len) invalid type argument for (counter = offset; counter < len+offset; counter++)printf("%x, ", *ptr[counter]); #endif The error is happening somewhere in the DFORC() macro. I guess my question is where is that exactly and how would I fix it? c pointers memset share|improve this question asked May 21 '14 at 2:27 skrillac 63 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted cbloc is a pointer to characters, so in DFORC, ptr is also a pointer to characters. The statement: printf("'%c', ", *ptr[counter]); First uses ptr as an array, accessing element counter of that array. This returns a char (not a char *). You then try to dereference that char, which is doesn't make sense, hence the error. To fix this, change that statement to either of the following statements: printf("'%c', ", ptr[counter]); printf("'%c', ", *(ptr + counter)); share|improve this answer answered May 21 '14 at 2:35 SirPentor 1,484717 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged c pointers memset or ask your own
Sign in Pricing Blog Support Search GitHub This repository Watch 4 Star 3 Fork 1 Intrepid/upc2c Code Issues 11 Pull requests 0 Projects 0 Pulse Graphs New issue Problems w/ ___errno on Solaris #112 Open PHHargrove opened this Issue Mar 2, 2015 · 16 comments Projects None yet Labels None yet Milestone No milestone Assignees PHHargrove 3 participants Intrepid Technology, Inc. member PHHargrove commented Mar 2, 2015 With clang-upc on Solaris/x86 and gcc or cc (Sun/Oracle compiler) as the back-end compiler, I see failures on upc_io_test.upc: [benchmarks/upc_io_test] FAILED: UPC-To-C Translation or Link error (NEW) cd /shared/upcnightly-32/cupc2c/work/dbg/upc-tests/benchmarks /export/home/phargrov/upcnightly-32/cupc2c/runtime/inst/bin/upcc -Ww,-Wno-duplicate-decl-specifier -Ww,-Werror=pointer-arith -g -network=smp -o upc_io_test upc_io_test.upc upcc: error compiling translated C code: upc_io_test.upc: In function 'doit': upc_io_test.upc:200:13: warning: implicit declaration of function '___errno' upc_io_test.upc:200:13: warning: nested extern declaration of '___errno' upc_io_test.upc:200:14: error: invalid type argument of unary '*' (have 'int') upc_io_test.upc:205:175: error: invalid type argument of unary '*' (have 'int') upc_io_test.upc:205:198: error: invalid type argument of unary '*' (have 'int') upc_io_test.upc:207:211: error: invalid type argument of unary '*' (have 'int') upc_io_test.upc:207:234: error: invalid type argument of unary '*' (have 'int') upc_io_test.upc:207:179: error: invalid type argument of unary '*' (have 'int') upc_io_test.upc:207:202: error: invalid type argument of unary '*' (have 'int') upc_io_test.upc:207:26: error: invalid type argument of unary '*' (have 'int') upc_io_test.upc:208:229: error: invalid type argument of unary '*' (have 'int') upc_io_test.upc:208:252: error: invalid type argument of unary '*' (have 'int') upc_io_test.upc:208:181: error: invalid type argument of una