Hello I am running a C++ code in the IAR Embedded Workbench and i am having a problem with these lines : float *temp1= new float[N]; float *temp2= new float[N]; .............. delete[] temp1; delete[] temp2; Are these declaration supported with this compiler or is there any other way of doing this? Moreover as i cannot use printf statement in IAR, i have tried to create a file pointer where the data could be written, but there is error (FILE *Fp) it says that FILE is undefined??Is there any one whose familiar with this? Thanks in advance! --------------------------------- Blab-away for as little as 1/min. Make PC-to-Phone Calls using Yahoo! Messenger with Voice.
IAR compiler and C++ code
Started by ●March 28, 2006
Reply by ●March 28, 20062006-03-28
Hi! wish_akuze wish_akuze wrote: > I am running a C++ code in the IAR Embedded Workbench and i am having a problem with these lines : > > float *temp1= new float[N]; > float *temp2= new float[N]; > .............. > > delete[] temp1; > delete[] temp2; > > Are these declaration supported with this compiler or is there any other way of doing this? Yes, the IAR compiler can handle C++ (well, actually, Embedded C++). However, you must manually specify the language in Project -> Options -> C/C++ Compiler -> Language. > Moreover as i cannot use printf statement in IAR, i have tried to create a file pointer where the data could be written, but there is error (FILE *Fp) it says that FILE is undefined??Is there any one whose familiar with this? You have to select the "full" version of the DLib library. Nethier CLib or the "normal" version of DLib have support for "FILE *". However, all libraries has support for plain printf:s. -- Anders Lindgren, IAR Systems -- Disclaimer: Opinions expressed in this posting are strictly my own and not necessarily those of my employer.
Reply by ●March 29, 20062006-03-29
Hello, After enabling the "full DLIB", the code was compiled with no errors! However when i added these file headers and disabled the watchodog timer: #define MSP430 #ifdef MSP430 #include "msp430x16x.h" #endif ........ #ifdef MSP430 WDTCTL = WDTPW + WDTHOLD ; /* Stop watchdog timer*/ #endif I got a bunch of 25 errors! at the defined function prototype: void calculate(int N, float *x,float *y); and the errors are such as: incomplete type not allowed, and expected brakets after int N, and float *x, and float*y....etc? Is there anything wrong using these pointers?? I don't understand why i got these errors. I have ran the same code in visual studio C++6 and it was ok, and of course i did not need to add the msp430 headers! The other thing is that the compiler is complaining about the the function's prototype and the functions itself : it says the variable calculate has been already defined!! Any ideas?? Thanks in advance Anders Lindgren <Anders.lindgren@Ande...> wrote: You have to select the "full" version of the DLib library. Nethier CLib or the "normal" version of DLib have support for "FILE *". However, all libraries has support for plain printf:s. -- Anders Lindgren, IAR Systems -- Disclaimer: Opinions expressed in this posting are strictly my own and not necessarily those of my employer. . --------------------------------- . --------------------------------- --------------------------------- New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.
Reply by ●March 29, 20062006-03-29
wish_akuze wish_akuze wrote: > Hello, > > After enabling the "full DLIB", the code was compiled with no errors! > However when i added these file headers and disabled the watchodog > timer: > > #define MSP430 > > #ifdef MSP430 > #include "msp430x16x.h" > #endif ........ > > #ifdef MSP430 > WDTCTL = WDTPW + WDTHOLD ; /* Stop watchdog timer*/ > #endif > I got a bunch of 25 errors! at the defined function prototype: void > calculate(int N, float *x,float *y); and the errors are such as: > incomplete type not allowed, and expected brakets after int N, and > float *x, and float*y....etc? Is there anything wrong using these > pointers?? That line looks ok to me -- maybe N is defined as a preprocessor macro, which fools the compiler. If you are unsure about a construction, try to make a very small example that contains your construction, if it works then the problem must be elsewhere. Another thing that could be the problem is if you're using so-called "variable length arrays", that is local arrays whose size is not constant, e.g: void test(int n) { float fs[n]; ... } Unfortunately we, like most microprocessor C implementations, do not support them. > I don't understand why i got these errors. I have ran the same code > in visual studio C++6 and it was ok, and of course i did not need to > add the msp430 headers! > > The other thing is that the compiler is complaining about the the > function's prototype and the functions itself : it says the variable > calculate has been already defined!! > > Any ideas?? None, not without actually seeing the code in question. -- Anders Lindgren, IAR Systems -- Disclaimer: Opinions expressed in this posting are strictly my own and not necessarily those of my employer.