I am trying to write a program which implements the Pop and Push functions. The problem is, I am trying to pass the pointer that points to integer Top to the function, so that this integer keeps changing, but when I try to compile I always get this line:
**error: called object is not a function or function pointer (*t)—
#include<stdio.h>
#include<stdlib.h>
#define MAX 10
int push(int stac[], int *v, int *t)
{
if((*t) == MAX-1)
{
return(0);
}
else
{
(*t)++;
stac[*t] = *v;
return *v;
}
}
int pop(int stac[], int *t)
{
int popped;
if((*t) == -1)
{
return(0);
}
else
{
popped = stac[*t]
(*t)--;
return popped;
}
}
int main()
{
int stack[MAX];
int value;
int choice;
int decision;
int top;
top = -1;
do{
printf("Enter 1 to push the valuen");
printf("Enter 2 to pop the valuen");
printf("Enter 3 to exitn");
scanf("%d", &choice);
if(choice == 1)
{
printf("Enter the value to be pushedn");
scanf("%d", &value);
decision = push(stack, &value, &top);
if(decision == 0)
{
printf("Sorry, but the stack is fulln");
}
else
{
printf("The value which is pushed is: %dn", decision);
}
}
else if(choice == 2)
{
decision = pop(stack, &top);
if(decision == 0)
{
printf("The stack is emptyn");
}
else
{
printf("The value which is popped is: %dn", decision);
}
}
}while(choice != 3);
printf("Top is %dn", top);
}
-
03-18-2012
#1

Registered User
Called Object type is not a function or function pointer (probably beginner mistake)
Hey guys, I’ve just started coding C about a week ago and I’m getting an error in two lines of code one saying «Called object type ‘int’ is not a function or function browser» and «Called object type ‘int’ is not a function or function browser». I’d like to know why that’s happening in my program but also what that means in general. Another one that isn’t actually failing the build is «Conversion specifies build type ‘double’ but the argument has type ‘double *’, and I was wondering what that means. All the errors are in the «a series» function. The point of the code in this section is to loop a certain number of times, (entered by the user(n)) adding a function during each iteration of the loop, with a time input (t). Thanks for the help. Here’s the code
Code:
#include <stdio.h> #include <time.h> #include <math.h> #define pi 3.141593 int aseries(); int bseries(); int cseries(); int main() { //Beginning program stuff //Defining variables to find the time time_t now; time(&now); printf("%sn", ctime(&now)); printf("--------------------------------------------------------------n"); //Main Program char choice; printf("What type of evaluation would you like to perform?nt1.)Calculate voltage for a given value of time.nt2.)Input t and epsilon.nt3.)Find the change in voltage between t2 and t1.nEnter '1' for choice one, '2' for choice two, or '3' for choice three: "); scanf("%d",&choice); if (choice == 1){ aseries(); } if (choice == 2){ bseries(); } if (choice == 3){ cseries(); } return 0; } int aseries() { double t; int n; double total=0; double v; //Prompting the user for time input printf("Enter the time you would like to evaluate the voltage at: "); scanf("%lf",&t); //Prompting the user for number of terms in the series printf("Enter the number of terms in the series you would like: "); scanf("%lf",&n); //Building the series for (int i=0;i<=n;i++){ total = total + ((1/((2(i)-1)^2))*cos(((2(i)-1)*pi*t)/3)) //This is where the "Called object type 'int'..." error is } v=(3/2)-(12/pow(pi,2))(total); //This is where the "Called object type 'double'..." error is printf("%lf",&v); //This is where the "Conversion specifics type..." error is return 0 ; } int bseries() { double t; double e; //Prompting the user for time input printf("Enter the time you would like to evaluate the voltage at: "); scanf("%lf",&t); //Prompting the user for epsilon input printf("Enter the epsilon value you would like to use: "); scanf("%lf",&e); return 0; } int cseries() { double t1; double t2; int n; //Prompt the user for time inputs printf("Enter the beginning of the time you would like to evaluate the voltage at: "); scanf("%lf",&t1); printf("Enter the end of the time you would like to evaluate the voltage at: "); scanf("%lf",&t2); //Prompting the user for number of terms in the series printf("Enter the number of terms in the series you would like: "); scanf("%lf",&n); return 0; }
Last edited by Ethan_K; 03-18-2012 at 09:43 PM.
-
03-18-2012
#2

ATH0
Next time, try including line numbers for those errors. Why did you feel the need to go in and manually color everything?
Code:
int n; ... printf("Enter the number of terms in the series you would like: "); scanf("%lf",&n);Quzah.
Hope is the first step on the road to disappointment.
-
03-18-2012
#3

Registered User
Originally Posted by quzah
Next time, try including line numbers for those errors. Why did you feel the need to go in and manually color everything?
Code:
int n; ... printf("Enter the number of terms in the series you would like: "); scanf("%lf",&n);Quzah.
The code was already colored from Xcode. And I changed the %lf to a %d, but it didn’t fix any of the errors.
-
03-18-2012
#4

ATH0
Code:
total = total + ((1/((2(i)-1)^2))
All of that is integer math. ^ is not power of, it’s XOR. I don’t know what you think 2(i) does, but it doesn’t do what you think it does.
Quzah.
Hope is the first step on the road to disappointment.
-
03-18-2012
#5

spurious conceit
Originally Posted by Ethan_K
The code was already colored from Xcode.
If you set whatever in Xcode so that it exports plain text instead, the forum will highlight and add line numbers. Then you can include the line number of the errors. That is a little simpler and more obvious than adding comments to the same effect.
Lose the address of operator & here:
The «called object…» errors are because you need to add some multiplication signs, *. You can’t use «2(3+1)», you have to use «2*(3+1)».
Beware what quzah said about ^ not being the operator you may think it is.
-
03-18-2012
#6

Registered User
Alright yeah thanks, I’m still adjusting to syntax differences between this and matlab. I switched out the ^ for the pow function. And after I removed the & everything appears to be working correctly, so thanks guys! And just to clear things up, the & just points to a variable, right? So for most things I don’t need a pointer, besides scanf()?
-
03-18-2012
#7

— — — — — — — —
Here is a better definition of PI (and note that manifest constants are conventionally spelled in uppercase). Put this after your includes at the top of the program. (The ifndef is just in case math.h has already defined it.)
Code:
#ifndef M_PI #define M_PI 3.1415926535897932385 #endif #define PI_SQUARED (M_PI * M_PI)
Note that because of the way integer division works in C, the expression (3 / 2) will give exactly 1. Better to simply use 1.5. Also, it’s often best to avoid the pow function for simply squaring a number. So taking all that on board, try something like:
Code:
double a; /* Give this a better name if you can think of one. */ . . . a = 2 * i - 1; total += 1 / (a * a) * cos(a * M_PI * t / 3) v = 1.5 - 12 / PI_SQUARED * total;
The cost of software maintenance increases with the square of the programmer’s creativity. — Robert D. Bliss
-
03-18-2012
#8

spurious conceit
Originally Posted by Ethan_K
Alright yeah thanks, I’m still adjusting to syntax differences between this and matlab. I switched out the ^ for the pow function. And after I removed the & everything appears to be working correctly, so thanks guys! And just to clear things up, the & just points to a variable, right? So for most things I don’t need a pointer, besides scanf()?
& returns the address of a variable (aka, a pointer to it). With the scanf() input functions, you want to pass in an address so scanf can write to it. With the printf() output functions, you are providing a value to read. So if you have an int x, x refers to that value; &x also refers to a value, but it is the value of the address where x is stored, which is usually not meaningful for output.
Screw around and have a look at the difference. If you are printing addresses on purpose, use %p (the p is for pointer).
-
03-19-2012
#9

Registered User
Alright, this thread has cleared up a ton of confusions, thanks everyone!
Edit:
Originally Posted by oogabooga
Note that because of the way integer division works in C, the expression (3 / 2) will give exactly 1. Better to simply use 1.5. Also, it’s often best to avoid the pow function for simply squaring a number.To tell C to do double/float division it seems like putting a decimal after the numbers works (e.g. 3.0/2.0) is that correct? And for the pow function, it’s better just to use multiplication because it takes less resources?
Last edited by Ethan_K; 03-19-2012 at 08:48 AM.
-
03-19-2012
#10

— — — — — — — —
Originally Posted by Ethan_K
To tell C to do double/float division it seems like putting a decimal after the numbers works (e.g. 3.0/2.0) is that correct? And for the pow function, it’s better just to use multiplication because it takes less resources?
Yep. Sounds like you’re getting the hang of it.
The cost of software maintenance increases with the square of the programmer’s creativity. — Robert D. Bliss
-
03-19-2012
#11

Registered User
Alright guys, everything is seemingly working correctly, as far as the compiler is concerned. However, something is going wrong when building the series: the math is going wrong after the first loop (The printf’s are in there just to see what’s going on in the loop). I made the series building equation it’s own function to save on retyping it.
Code:
double buildseries(double t, int n){ double a=0,v=0,total=0; for (int i=1;i<=n;i++){ printf("i = %dn",i); a = 2.0 * i - 1.0; printf("a = %lfn",a); total += 1.0 / (a * a) * cos(a * M_PI * t / 3.0); printf("total = %lfn",total); } v = (3.0/2.0) - 12 / PI_SQUARED * total; return v;
I tested the output with t = 2.4 and n = 3 and this is the output:
i = 1
a = 1.000000
total = -0.809017
i = 2
a = 3.000000
total = -0.774682
i = 3
a = 5.000000
total = -0.734682
t = 2.4
n = 3
V = 2.393266The a values are correct, but the total values are wrong after the first one and I’m not sure what’s causing it. According to my calculator (which is in radians) the second ‘total’ value should be .0343352216, and the third ‘total’ value should be .04.
Thanks again guys.
-
03-19-2012
#12

C++ Witch
What is the formula that you are trying to implement? Maybe the bug is with that implementation.
Originally Posted by Bjarne Stroustrup (2000-10-14)I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. «Finding the smallest program that demonstrates the error» is a powerful debugging tool.
Look up a C++ Reference and learn How To Ask Questions The Smart Way
-
03-19-2012
#13

Registered User
Originally Posted by laserlight
What is the formula that you are trying to implement? Maybe the bug is with that implementation.
-
03-20-2012
#14

Registered User
Whoops I was making a very foolish mistake and calculating the total each time while checking the math, not actual the sum of the totals each time- so everything is working fine. Time to stop late night coding…
|
Smart1706 0 / 0 / 0 Регистрация: 05.10.2017 Сообщений: 6 |
||||
|
1 |
||||
Посмотрите, пожалуйста, что не так, не могу исправить ошибку(05.10.2017, 23:15. Показов 4020. Ответов 7 Метки нет (Все метки)
Задание: решите уравнение x — (x^2 / (1 + sin^2 (x+y+z)) в С а вот, что получилось:
Running «/home/ubuntu/workspace/lab3/task3.c» Process exited with code: 1
__________________
0 |
|
3528 / 2183 / 400 Регистрация: 09.09.2017 Сообщений: 8,988 |
|
|
05.10.2017, 23:50 |
2 |
|
у вас sin объявлено локальной переменной, хотя это математическая функция. Еще не помешает указать линкеру -lm если еще не сделано
1 |
|
0 / 0 / 0 Регистрация: 05.10.2017 Сообщений: 6 |
|
|
06.10.2017, 00:29 [ТС] |
3 |
|
COKPOWEHEU, видимо, мой уровень ниже начинающего — даже не представляю, как это всё сделать. Буду учиться. Спасибо
0 |
|
3528 / 2183 / 400 Регистрация: 09.09.2017 Сообщений: 8,988 |
|
|
06.10.2017, 09:25 |
4 |
|
sin как переменная у вас нигде не используется. Зачем она вообще там объявлена? Уберите ее объявление оттуда и все.
1 |
|
0 / 0 / 0 Регистрация: 05.10.2017 Сообщений: 6 |
|
|
06.10.2017, 09:56 [ТС] |
5 |
|
COKPOWEHEU, спасибо, количество ошибок сократилось до одной:
0 |
|
3528 / 2183 / 400 Регистрация: 09.09.2017 Сообщений: 8,988 |
|
|
06.10.2017, 10:05 |
6 |
|
Покажите исправленный код и команду, которой компилируете.
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token «Отсутствует знак равно, запятая, точка с запятой или атрибут перед точкой». Проблема очевидно в исходном коде, но с ходу я точку не нашел. Там точно не указан номер строки?
1 |
|
Smart1706 0 / 0 / 0 Регистрация: 05.10.2017 Сообщений: 6 |
||||
|
06.10.2017, 10:09 [ТС] |
7 |
|||
|
COKPOWEHEU,
Добавлено через 45 секунд
0 |
|
3528 / 2183 / 400 Регистрация: 09.09.2017 Сообщений: 8,988 |
|
|
06.10.2017, 11:10 |
8 |
|
#include <math.h> это прямо в коде программы??? Нет, это нужно указать компилятору!
float x,y,z,F; Либо используйте «%f» (float), либо, если используете «%lf», объявите F как double.
Покажите исправленный код и команду, которой компилируете.
0 |
|
IT_Exp Эксперт 87844 / 49110 / 22898 Регистрация: 17.06.2006 Сообщений: 92,604 |
06.10.2017, 11:10 |
|
Помогаю со студенческими работами здесь
Пожалуйста посмотрите что тут не так? не могу додумать,посмотрите что не так
int main() { Искать еще темы с ответами Или воспользуйтесь поиском по форуму: 8 |
That’s not how I’d do it.
…
then invoke with a function-like macro call. e.g:
SET_TCB0_MODE(TCB0_MODE_FREQ_MEASUREMENT);
Note that both the bit constants to be assigned and the mask for them are shifted ‘up’ the register by pozn so that enum can be used to declare them even for groups of bits that don’t include the LSB of the register. If you need to skip a bit value in the enum, e.g. 0b101, declare it as …_RESERVED101
This is good, and only a modest variation on the way Atmel did it (at least for the MEGA family) already. A random example from an xmega header:
/* Quadrature Decoder Index Recognition Mode */
typedef enum EVSYS_QDIRM_enum
{
EVSYS_QDIRM_00_gc = (0x00<<5), /* QDPH0 = 0, QDPH90 = 0 */
EVSYS_QDIRM_01_gc = (0x01<<5), /* QDPH0 = 0, QDPH90 = 1 */
EVSYS_QDIRM_10_gc = (0x02<<5), /* QDPH0 = 1, QDPH90 = 0 */
EVSYS_QDIRM_11_gc = (0x03<<5), /* QDPH0 = 1, QDPH90 = 1 */
} EVSYS_QDIRM_t;
«_gc» stands for «group configuration», so it is the pattern of bits to set for the desired configuration. The register is masked with the «_gm» (group mask), and the individual bits with «_bm» (bit mask).
Therefore, a basic modify statement has the form:
port.register = (port.register & ~port_bitgroup_gm) | port_bitgroup_state_gc;
The «& ~» reads the existing register value and zeroes the desired bits; the | puts back in the desired bits. (The bitmasking can be omitted in the initialization routine, where you don’t need to worry about the initial state of other bits in the register.)
The only reason you should need/want to get fancier, is to be able to change all «port.register» and bitgroup/state references, to a more general definition, in your own headers.
This is more or less what Ian is doing: putting the whole assignment into a macro function.
By encapsulating the assignment in a more general macro, you only have to change, say, a few dozens of register, bit and group names.
You definitely don’t want to maintain exhaustive lists of bits, that will accumulate errors faster than you can say «refactor»!
At the very least, if you insist on building such lists, write a tool to generate them! That’s how the pros make their headers (well, at least I would hope so..). That’s also what their headers are for. Use them!
With this additional level of naming indirection, you can — if nothing else — use them in the same way as the XMEGA style headers, even for platforms that don’t use that format (e.g., original MEGA). You can get consistent naming conventions across families, or sub-families anyway. It’s probably a fair method even to support completely different platforms, too (ARM?)! Though, that’s probably optimistic, and you may need more (or fewer) statements, on platforms quite that different (i.e., wider-bit devices probably use fewer registers to hold all their control/status bits).
Generality is the key here. You don’t want to go more specific, less general. You must only go more general. To go more specific, means more code refactoring. More work, more frustration!
It also means this: if you don’t know, in what directions you should generalize — if you aren’t very familiar with the ecosystems of microcontrollers in general — you probably shouldn’t do it at all, and just leave it at the family level.
Make it obvious to the reader, which functions/defines need to be checked/changed, to migrate to a different device/family, and leave it at that.
Better still, if it’s an open project: let other, more experienced programmers fork and improve it. If you don’t have that kind of breadth of knowledge, don’t make it up as you go — take advantage of those more experienced!
Tim
У меня такой код:
z=x-~y-1;
printf("%d",z);
z=(x^y)+2(x&y);
printf("%d",z);
z=(x|y)+(x&y);
printf("%d",z);
z=2(x|y)-(x^y);
printf("%d",z);
Я получаю это сообщение об ошибке:
10:11: error: called object is not a function or function pointer
z=(x^y)+2(x&y);
^
Язык — C. Почему это произошло?
2 ответа
Лучший ответ
Что касается того, что означает ошибка: 2(x&y) говорит компилятору вызвать функцию 2, передавая x&y в качестве аргумента (точно так же, как printf("hi") означает « call {{ X4}} и передайте "hi" в качестве аргумента «).
Но 2 не является функцией, поэтому вы получаете ошибку типа. Синтаксически говоря, когда у вас есть значение, за которым следует (, это вызов функции.
1
melpomene
2 Мар 2017 в 16:19
+ Изменить
z=(x^y)+2(x&y);
К
z=(x^y)+2*(x&y);
А также
z=2(x|y)-(x^y);
К
z=2*(x|y)-(x^y);
Вам нужен оператор умножения, если умножение — это то, что вы хотели.
1
vatsug
2 Мар 2017 в 16:06
Hello,
trying to compile CoreBreach for the Ubuntu gaming site playdeb.net there is this compilation error:
(quantal-amd64)korn@pc:~/packages/corebreach/corebreach-0.0.0+git20121126/CoreBreach$ CC=clang GNUSTEP_MAKEFILES=/usr/share/GNUstep/Makefiles make
This is gnustep-make 2.6.2. Type ‘make print-gnustep-make-help’ for help.
Making all for app CoreBreach…
Compiling file ../Core3D/_DEPENDENCIES/sources/freetype-gl/texture-atlas.c …
Compiling file ../Core3D/_DEPENDENCIES/sources/freetype-gl/texture-font.c …
Compiling file ../Core3D/_DEPENDENCIES/sources/freetype-gl/vector.c …
Compiling file ../Core3D/_DEPENDENCIES/sources/freetype-gl/vertex-buffer.c …
In file included from ../Core3D/_DEPENDENCIES/sources/freetype-gl/vertex-buffer.c:38:
../Core3D/_DEPENDENCIES/sources/freetype-gl//vertex-buffer.h:442:3: error:
expected identifier or ‘(‘
GL_TYPE( char ctype );
^
/usr/include/GL/glext.h:2972:43: note: expanded from:
define GL_TYPE 0x92FA
../Core3D/_DEPENDENCIES/sources/freetype-gl/vertex-buffer.c:592:34: error:
called object type ‘int’ is not a function or function pointer
GLenum type = GL_TYPE( ctype );
~~~~~~~^
../Core3D/_DEPENDENCIES/sources/freetype-gl/vertex-buffer.c:600:34: error:
called object type ‘int’ is not a function or function pointer
GLenum type = GL_TYPE( ctype );
~~~~~~~^
../Core3D/_DEPENDENCIES/sources/freetype-gl/vertex-buffer.c:612:30: error:
called object type ‘int’ is not a function or function pointer
GLenum type = GL_TYPE( ctype );
~~~~~~~^
../Core3D/_DEPENDENCIES/sources/freetype-gl/vertex-buffer.c:586:31: warning:
array index of ‘2’ indexes past the end of an array (that contains 2
elements) [-Warray-bounds]
p = strpbrk ( format, «n» );
~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/x86_64-linux-gnu/bits/string2.h:1097:39: note: expanded from:
: ((__a2 = ((__const char *) (accept))[2], __a2 == »)
^ ~
../Core3D/_DEPENDENCIES/sources/freetype-gl/vertex-buffer.c:586:31: warning:
array index of ‘3’ indexes past the end of an array (that contains 2
elements) [-Warray-bounds]
p = strpbrk ( format, «n» );
~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/x86_64-linux-gnu/bits/string2.h:1099:27: note: expanded from:
: (((__const char *) (accept))[3] == »
^ ~
../Core3D/_DEPENDENCIES/sources/freetype-gl/vertex-buffer.c:745:1: error:
expected identifier or ‘(‘
GL_TYPE( char ctype )
^
/usr/include/GL/glext.h:2972:43: note: expanded from:
define GL_TYPE 0x92FA
2 warnings and 5 errors generated.
make[3]: *** [obj/CoreBreach.obj/../Core3D/_DEPENDENCIES/sources/freetype-gl/vertex-buffer.c.o] Error 1
make[2]: *** [internal-app-run-compile-submake] Error 2
make[1]: *** [CoreBreach.all.app.variables] Error 2
make: *** [internal-all] Error 2
it seems there is an incompatibility between one of our dependencies (freetype-gl) and your version of glext.h. i’ve reported the problem upstream and tried to include an fix. you could update Core3D and try again.
Thank you, now I do not get this error any longer.
But unfortunately the libgnustep-gui-dev package in Ubuntu 12.10 is not new enough:
libgnustep-gui-dev:
Installed: (none)
Candidate: 0.20.0-3ubuntu1
Version table:
0.20.0-3ubuntu1 0
500 http://de.archive.ubuntu.com/ubuntu/ quantal/universe amd64 Packages
(quantal-amd64)korn@pc:~/packages/corebreach/corebreach-0.0.0+git20121126/CoreBreach$ CC=clang GNUSTEP_MAKEFILES=/usr/share/GNUstep/Makefiles makeThis is gnustep-make 2.6.2. Type ‘make print-gnustep-make-help’ for help.
Making all for app CoreBreach…
Compiling file Classes/UpgradeHandler.m …
In file included from :141:
In file included from :13:
../Core3D/Utilities/Core3D_Prefix.pch:167:18: warning: #warning need gnustep
base 1.24.0 or later [-W#warnings]
#warning need gnustep base 1.24.0 or later
^
../Core3D/Utilities/Core3D_Prefix.pch:172:18: warning: #warning need gnustep gui
0.22 or later [-W#warnings]
#warning need gnustep gui 0.22 or later
^
2 warnings generated.
Compiling file Classes/ApplicationSubclass.m …
In file included from :141:
In file included from :13:
../Core3D/Utilities/Core3D_Prefix.pch:167:18: warning: #warning need gnustep
base 1.24.0 or later [-W#warnings]
#warning need gnustep base 1.24.0 or later
^
../Core3D/Utilities/Core3D_Prefix.pch:172:18: warning: #warning need gnustep gui
0.22 or later [-W#warnings]
#warning need gnustep gui 0.22 or later
^
2 warnings generated.
Compiling file Classes/ApplicationDelegate.m …
In file included from :141:
In file included from :13:
../Core3D/Utilities/Core3D_Prefix.pch:167:18: warning: #warning need gnustep
base 1.24.0 or later [-W#warnings]
#warning need gnustep base 1.24.0 or later
^
../Core3D/Utilities/Core3D_Prefix.pch:172:18: warning: #warning need gnustep gui
0.22 or later [-W#warnings]
#warning need gnustep gui 0.22 or later
^
2 warnings generated.
Compiling file OtherSources/NSTextField+AutoFontsize.m …
In file included from :141:
In file included from :13:
../Core3D/Utilities/Core3D_Prefix.pch:167:18: warning: #warning need gnustep
base 1.24.0 or later [-W#warnings]
#warning need gnustep base 1.24.0 or later
^
../Core3D/Utilities/Core3D_Prefix.pch:172:18: warning: #warning need gnustep gui
0.22 or later [-W#warnings]
#warning need gnustep gui 0.22 or later
^
2 warnings generated.
Compiling file OtherSources/NSView+Snapshot.m …
In file included from :141:
In file included from :13:
../Core3D/Utilities/Core3D_Prefix.pch:167:18: warning: #warning need gnustep
base 1.24.0 or later [-W#warnings]
#warning need gnustep base 1.24.0 or later
^
../Core3D/Utilities/Core3D_Prefix.pch:172:18: warning: #warning need gnustep gui
0.22 or later [-W#warnings]
#warning need gnustep gui 0.22 or later
^
2 warnings generated.
Compiling file OtherSources/NSView+GridCalculation.m …
In file included from :141:
In file included from :13:
../Core3D/Utilities/Core3D_Prefix.pch:167:18: warning: #warning need gnustep
base 1.24.0 or later [-W#warnings]
#warning need gnustep base 1.24.0 or later
^
../Core3D/Utilities/Core3D_Prefix.pch:172:18: warning: #warning need gnustep gui
0.22 or later [-W#warnings]
#warning need gnustep gui 0.22 or later
^
2 warnings generated.
Compiling file OtherSources/ClickableImageView.m …
In file included from :141:
In file included from :13:
../Core3D/Utilities/Core3D_Prefix.pch:167:18: warning: #warning need gnustep
base 1.24.0 or later [-W#warnings]
#warning need gnustep base 1.24.0 or later
^
../Core3D/Utilities/Core3D_Prefix.pch:172:18: warning: #warning need gnustep gui
0.22 or later [-W#warnings]
#warning need gnustep gui 0.22 or later
^
2 warnings generated.
Compiling file OtherSources/HIDSupport_SDL.m …
In file included from :141:
In file included from :13:
../Core3D/Utilities/Core3D_Prefix.pch:167:18: warning: #warning need gnustep
base 1.24.0 or later [-W#warnings]
#warning need gnustep base 1.24.0 or later
^
../Core3D/Utilities/Core3D_Prefix.pch:172:18: warning: #warning need gnustep gui
0.22 or later [-W#warnings]
#warning need gnustep gui 0.22 or later
^
2 warnings generated.
Compiling file OtherSources/HostInformation.m …
In file included from :141:
In file included from :13:
../Core3D/Utilities/Core3D_Prefix.pch:167:18: warning: #warning need gnustep
base 1.24.0 or later [-W#warnings]
#warning need gnustep base 1.24.0 or later
^
../Core3D/Utilities/Core3D_Prefix.pch:172:18: warning: #warning need gnustep gui
0.22 or later [-W#warnings]
#warning need gnustep gui 0.22 or later
^
2 warnings generated.
Compiling file ../Core3D/Utilities/opengl_linux.cpp …
g++: error: unrecognized command line option ‘-Qunused-arguments’
But unfortunately the libgnustep-gui-dev package in Ubuntu 12.10 is not new enough:
yes you need packages that aren’t older than a year.
Compiling file ../Core3D/Utilities/opengl_linux.cpp …
g++: error: unrecognized command line option ‘-Qunused-arguments’
here is the reason compilation aborts, you didn’t set the c++ compiler to clang.
try adding CXX=clang to you command line.
Thank you.
There is this error now:
../Core3D/CoreEngine/Scene.mm:103:34: error: cannot initialize a parameter of
type ‘float *’ with an lvalue of type ‘CGFloat [4]’
[value getComponents:c];
On 01.12.2012, at 20:50, Christoph Korn notifications@github.com wrote:
Thank you.
There is this error now:
../Core3D/CoreEngine/Scene.mm:103:34: error: cannot initialize a parameter of
type ‘float *’ with an lvalue of type ‘CGFloat [4]’
[value getComponents:c];
hello again
weird, your clang version is more strict.
a simple cast, i.e. changing the line to «[value getComponents:(float *)c];» should fix it, but i can only test it and update the repository in about a day…
weird, it seems your clang version is more strict. a simple cast should fix that, but i can only update the repository in about a day.
Thank you.
There is this error now:
../Core3D/CoreEngine/Scene.mm:103:34: error: cannot initialize a parameter of
type ‘float *’ with an lvalue of type ‘CGFloat [4]’
[value getComponents:c];—
Reply to this email directly or view it on GitHub.
after more investigation this is not a difference of the compiler version, but because of the too-old gnustep version you are using.
i’ve tried to add a fix but i’m not sure there is any worth in trying to get it to compile on versions of gnustep that are too old anyway.
Ok, I think then I have to wait until Ubuntu 13.04 which has a more recent gnustep package.
i’m looking forward to it 😉
See more:
I want to iterate over a product array.The pointer that I want to use is Order, yet I receive an error stating;
error: called object is not a function or function pointer 47 | if(orders->product_items(j).sku == products[t].sku) | ^~~~~~ hw4.c:49:22: error: called object is not a function or function pointer 49 | TotalCost += (orders->product_items(j).quantity * products[t].price); | ^~~~~~
This is an updated question.
These are the two files, I’ve downloaded.
Orders.H
struct product { short sku; char *name; float price; }; struct item { short sku; short quantity; }; struct order { short order_id; char *customer_name; short num_products; struct item *product_items; }; struct order * read_orders(const char *filename, short *num_orders);
Orders.C
#include <inttypes.h> #include "orders.h" struct order * read_orders(const char *filename, short *num_orders) { int fd; fd = open(filename, O_RDONLY); int err = fd; if (err == -1) { return NULL; } read(fd, num_orders, sizeof(*num_orders)); struct order *orders = (struct order *) calloc(*num_orders, sizeof(struct order)); int i; for (i=0; i<*num_orders; i++) { struct order *op = &orders[i]; read(fd, &op->order_id, sizeof(op->order_id)); uint32_t sz; read(fd, &sz, sizeof(sz)); op->customer_name = (char *)malloc(sz+1); read(fd, op->customer_name, sz); op->customer_name[sz] = 0; read(fd, &op->num_products, sizeof(op->num_products)); op->product_items = (struct item *) calloc(op->num_products, sizeof(struct item)); int j; for (j=0; j<op->num_products; j++) { struct item *ip = &(op->product_items[j]); read(fd, &ip->sku, sizeof(ip->sku)); read(fd, &ip->quantity, sizeof(ip->quantity)); } } close(fd); return orders; }
It’s only this slight part of the code mentioned above, that’s been troubling me. Other than that, the remainder of the code I believe should be fine. I would want assistance but not the answer. I also cannot make any modifications to this code before my first loop that iterates over the orders array.
to run the code; gcc -o hw4 hw4.c orders.c
What I have tried:
<pre>#include <stdio.h> #include <stdlib.h> #include "orders.h" struct product products[] = { { 1234, "Bread", 2.99 }, { 5678, "Milk", 4.19 }, { 9012, "Eggs", 3.49 }, { 3456, "Butter", 3.99 }, { 7890, "Juice", 2.49 }, { 2345, "Muffin", 1.49 } }; int main() { short num_orders; struct order *orders = read_orders("orders.db", &num_orders); if (orders == NULL) { printf("Order database does not existn"); } for (int i = 0; i < num_orders; i++) { float TotalCost = 0; printf("Order ID: %hd", orders[i].order_id); printf("Name: %sn", orders[i].customer_name); for (int j = 0; j < orders[i].num_products; j++) { for (int t = 0; t< 6; t++) { if(orders->product_items(j).sku == products[t].sku) { TotalCost += (orders->product_items(j).quantity * products[t].price); printf("%s %hd %f/n", products[t].name, orders->product_items[j].quantity, products[t].price); } } } printf("Total: %fn",TotalCost); printf("n"); } }

Что здесь не так? Посмотрите пожалуйста