Home > invalid type > gcc error invalid type argument of 'unary

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 int main(){ int b = 10; //assign the integer 10 to variable 'b' int *a; //declare invalid type argument of unary ‘*’ (have ‘double’) a pointer to an integer 'a' a=(int *)&b; //Get the memory location of variable 'b' cast it //to an int pointer and assign it to pointer 'a' int *c; //declare a pointer to an integer 'c' c=(int *)&a; //Get the memory location of variable 'a' which is //a pointer to 'b'. Cast that to an int pointer //and assign it to pointer 'c'. printf("%d",(**c)); //ERROR HAPPENS HERE. return 0; } Compiler produces an error: error: invalid type argument of ‘unary *’ (have ‘int’)

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 int main(){ int b=10; int *a; a=&b; int **c; c=&a; printf("%d",(**c)); //successfully prints 10 return 0; } share|improve this answer edited Sep 30 '13 at 19:24 Eric Leschinski 46.7k23221190 answered Mar 28 '11 at 7:41 codaddict 251k50362443 3 Also note the lack of casts in the answer. The casts in the question hide the problems on the line that is assigning an int ** to a int *. (c=(int *)&a;) –Thanatos Sep 30 '13 at 22:54 add a comment| up vote 8 down vote Barebones C program to produce the above error: #include using namespace std; int main(){ char *p; *p = 'c'; cout << *p[0]; //error: invalid type argument of `unary *' //peeking too deeply into p, that's a paddlin. cout << **p; //error: invalid type argument of `unary *' //peeking too deeply into p, you better believe that's a paddlin. } ELI5: You have a big plasma TV cardboard box that contains a small Jewelry box that contains a diamond. You asked me to get the cardboard box, open the box and ge

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 2 getinput() 3 { 4 int *employeeSalary[5]; 5 int i; 6 for(i=0;i<5;i++) 7 { 8 printf("Enter details of employee no. %d :",i+1); 9 scanf("%d",&employeeSalary[i]); 10 } 11 return(*employeeSalary); 12 } 13 14 int payrise(int *employeeSalary[]) 15 { 16 int *newSalary = ((employeeSalary*0.20)*100); 17 return(*newSalary); 18 } 19 20 int highestSalary(int *newSalary) 21 { 22 int i = 0; 23 int biggestSalary; 24 int element; 25 if(newSalary[i] >= newSalary[i]) 26 { 27 biggestSalary = newSalary[i]; 28 element = i; 29 } 30 return(biggestSalary, element); 31 } 32 33 void display(int *employeeSalary, int *newSalary, int biggestSalary, int element) 34 { 35 printf("The old salary was %d and the new one is %d ", employeeSalary, newSalary); 36 printf("The biggest salaray is %d in element %d", biggestSalary, element); 37 } 38 39 40 int main() 41 { 42 int initialSalary = getinput(); 43 int payIncrease = payrise(initialSalary); 44 int largestSalary = highestSalary(payIncrease); 45 display(initialSalary, payIncrease, largestSalary); 46 return(0); 47 } These are the errors im getting 11: error: invalid type argument of ‘unary *’ (have ‘int’) 16: error: invalid operands to binary * (have ‘int ***’ and ‘double’) 17: error: invalid type argument of ‘unary *’ (have ‘int’) 45: error: too few arguments to function ‘display

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

 

Related content

compile error invalid type xmldom

Compile Error Invalid Type Xmldom table id toc tbody tr td div id toctitle Contents div ul li a href Apex Invalid Type Class a li li a href Apex Invalid Type Int a li ul td tr tbody table p Release Overview p h id Apex Invalid Type Class p Trailhead Books Cheat Sheets On-Demand Webinars Certification Blogs Tools invalid type responsehandler Force com IDE Lightning Design System Source Code Scanner More Tools Toolkits By Topic App p h id Apex Invalid Type Int p Distribution App Logic Architect Database Lightning Mobile Integration Security User Interface Websites Community Developer

ebook library error invalid type

Ebook Library Error Invalid Type table id toc tbody tr td div id toctitle Contents div ul li a href Multilingual User Interface Pack Office a li li a href Multilingual User Interface Pack Office a li ul td tr tbody table p games PC games old format or invalid type library excel c Windows games Windows phone games Entertainment All Entertainment old format or invalid type library exception from hresult x type e unsupformat Movies TV Music Business Education Business Students educators old format or invalid type library exception from hresult x type e uns format Developers Sale Sale

error #171 invalid type conversion

Error Invalid Type Conversion table id toc tbody tr td div id toctitle Contents div ul li a href On message Invalid Type Conversion a li ul td tr tbody table p 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 relatedl site About Us Learn more about Stack Overflow the company invalid type conversion c Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs static cast invalid type conversion Documentation Tags Users Badges Ask Question x

error in model.frame.default invalid type closure for variable

Error In Model frame default Invalid Type Closure For Variable table id toc tbody tr td div id toctitle Contents div ul li a href Aggregate Na action In R a li li a href Invalid Type list For Variable a li ul td tr tbody table p here for a quick overview of the site Help relatedl Center Detailed answers to any questions you might invalid type closure of argument r have Meta Discuss the workings and policies of this site About p h id Aggregate Na action In R p Us Learn more about Stack Overflow the company

error invalid type argument of unary have ong int

Error Invalid Type Argument Of Unary Have Ong Int table id toc tbody tr td div id toctitle Contents div ul li a href Error Invalid Type Argument Of Unary have double a li li a href Error Invalid Type Argument Of Unary have char a li li a href Invalid Type Argument Of Unary have float a li li a href Invalid Type Argument Of Unary have char a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and

error invalid type for array subscript

Error Invalid Type For Array Subscript table id toc tbody tr td div id toctitle Contents div ul li a href Invalid Types For Array Subscript C a li li a href Invalid Types For Array Subscript Double Int a li li a href Invalid Types int Int For Array Subscript Arduino a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies relatedl of this site About Us Learn more about Stack Overflow error invalid types int int

error invalid type argument of unary have nt

Error Invalid Type Argument Of Unary Have Nt table id toc tbody tr td div id toctitle Contents div ul li a href Invalid Type Argument Of Unary have int C a li li a href Invalid Type Argument Of Unary have char a li li a href Invalid Type Argument Of Unary have double a li li a href Invalid Type Argument Of Unary have char a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta relatedl Discuss the workings and policies

error invalid type of argument of unary

Error Invalid Type Of Argument Of Unary table id toc tbody tr td div id toctitle Contents div ul li a href Error Invalid Type Argument Of Unary have double a li li a href Error Invalid Type Argument Of Unary have int a li li a href Error Invalid Type Argument Of Unary have int a li ul td tr tbody table p 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 relatedl this site About Us Learn more about Stack Overflow the