Hi,
When creating a macro with an array (of bytes) as parameter flowcode generates code the preprocessor does not accept.
In the generated c code (lines 50+51):
//Macro function declarations
void FCM_testMacro(char FCL_DATA[10]);
This generates the following errors when trying to generate a HEX file (see below for full output):
ref.c(51): error: missing right paren
ref.c(51): error: missing semicolon
ref.c(51): error: failure
What do I need to do to solve this?
Project generating the error is attached.
Best regards,
Jac
Full output of the attempted compile:
File name: Z:\flowcode\ref.c
Generated by: Flowcode v3.4.7.48
Date: Friday, September 05, 2008 16:53:43
Licence: Professional
http://www.matrixmultimedia.com
Launching the compiler...
C:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\boostc.pic16.flowcode.exe -v -t PIC16F88 "ref.c"
BoostC Optimizing C Compiler Version 6.70 (for PIC16 architecture)
http://www.sourceboost.com
Copyright(C) 2004-2007 Pavel Baranov
Copyright(C) 2004-2007 David Hobday
Licensed to FlowCode User under Single user Pro License for 1 node(s)
Limitations: PIC12,PIC16 max code size:Unlimited, max RAM banks:Unlimited
ref.c
Starting preprocessor: "C:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\pp.exe" Z:\flowcode\ref.c -i "C:\Program Files\Matrix Multimedia\Flowcode V3\BoostC\include" -d _PIC16F88 -la -c2 -o ref.pp -v -d _BOOSTC -d _PIC16
Z:\flowcode\ref.c(51): error: missing right paren
Z:\flowcode\ref.c(51): error: missing semicolon
Z:\flowcode\ref.c(51): error: failure
failure
...................
Return code = 1
Flowcode was unable to compile the flowchart's C code due to the following errors:
If your flowchart contains C code, please review this carefully. If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.
FINISHED
Macro with array as parameter fails in code generation
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Macro with array as parameter fails in code generation
- Attachments
-
- ref.fcf
- ref.fcf
- (3 KiB) Downloaded 474 times
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
- Steve
- Matrix Staff
- Posts: 3424
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
- Contact:
Re: Macro with array as parameter fails in code generation
At the moment, there is no way of passing an array as a aprameter to a macro.
Actually, there may be a way around this. A "string" variable is essentially an array of bytes, so you may be able to use this as a parameter instead. It looks a big ugly in simulation (because the parameter is displayed as a string rather than an array of bytes), but it should work ok. See the attached for a quick example.
Actually, there may be a way around this. A "string" variable is essentially an array of bytes, so you may be able to use this as a parameter instead. It looks a big ugly in simulation (because the parameter is displayed as a string rather than an array of bytes), but it should work ok. See the attached for a quick example.
- Attachments
-
- ref.fcf
- (3.5 KiB) Downloaded 608 times
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: Macro with array as parameter fails in code generation
Hi Steve,
Actually, I found a way to pass arrays to a macro:
* First define the array parameter with a size. (a[10])
* Next create the code in the macro, this step needs the array size to include all element directly accessed (something like a[3] == 1 requires the array to be defined with at least 4 elements.)
* Finally when the flow for the macro is done, edit the macro properties and remove the size from the array parameter. (a[])
Before editing any array references in the macro the array size needs to be re-inserted, to be taken out before compilation.
I would prefer a more straight forward way, and will try you suggestion as the number of steps involved in my work-around makes things error prone.
Best regards,
Jac
Actually, I found a way to pass arrays to a macro:
* First define the array parameter with a size. (a[10])
* Next create the code in the macro, this step needs the array size to include all element directly accessed (something like a[3] == 1 requires the array to be defined with at least 4 elements.)
* Finally when the flow for the macro is done, edit the macro properties and remove the size from the array parameter. (a[])
Before editing any array references in the macro the array size needs to be re-inserted, to be taken out before compilation.
I would prefer a more straight forward way, and will try you suggestion as the number of steps involved in my work-around makes things error prone.
Best regards,
Jac
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
- Steve
- Matrix Staff
- Posts: 3424
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
- Contact:
Re: Macro with array as parameter fails in code generation
Hello Jac,
Yes - I can see that this method is error prone. I will add "passing arrays to macros" to the list for Flowcode v4.
By the way, I tried what you suggested but I could not get it to work - neither simulation nor compilation worked for me. I tried to create a simple program that would return the sum total of an array (passing a byte array with 5 entries and returning the sum of the array elements).
Do you have a small example file that you have made so I can see what I am aiming for?
Yes - I can see that this method is error prone. I will add "passing arrays to macros" to the list for Flowcode v4.
By the way, I tried what you suggested but I could not get it to work - neither simulation nor compilation worked for me. I tried to create a simple program that would return the sum total of an array (passing a byte array with 5 entries and returning the sum of the array elements).
Do you have a small example file that you have made so I can see what I am aiming for?
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: Macro with array as parameter fails in code generation
Steve,
While trying to create a simple example I found I wasn't able to call the macro with an array. I did not notice this before because the code I have been working on calls the macro from custom_code so the caller is in C code, not the graphic program flow.
Best regards,
Jac
While trying to create a simple example I found I wasn't able to call the macro with an array. I did not notice this before because the code I have been working on calls the macro from custom_code so the caller is in C code, not the graphic program flow.
Best regards,
Jac
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis