View previous topic :: View next topic |
Author |
Message |
davidfsauri
Joined: 12 Aug 2019 Posts: 2 Location: Merida, Mexico
|
Error 51: Expecting Function Name |
Posted: Mon Aug 12, 2019 1:32 pm |
|
|
Hi, I've been trying to compile this code but I don't know what's wrong.
I have reviewed it a thousand times and have not yet been able to find
the solution. I hope you help me please.
+++++++++++++++++++++
The original poster removed his
own code due to embarrassment.
- Forum Moderator
+++++++++++++++++++++
Last edited by davidfsauri on Mon Aug 19, 2019 7:41 am; edited 1 time in total |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19872
|
|
Posted: Mon Aug 12, 2019 1:37 pm |
|
|
1) Use the code buttons when posting code. Otherwise it becomes very
hard for us to read.
2) It looks like you have almost all your code inside an interrupt handler.
Don't.
Interrupt handlers should be short and quick. No complicated maths,
no delays, etc. etc.
3) The actual error though is caused by lcd_putc. You have a variable called
'lcd_putc', no function of that name. You are then trying to use this in
printf, where a function name is expected. |
|
 |
davidfsauri
Joined: 12 Aug 2019 Posts: 2 Location: Merida, Mexico
|
Sorry |
Posted: Mon Aug 12, 2019 1:57 pm |
|
|
[code]
I do not know why I can do to solve that, can you explain me that, please.
+++++++++++++++++++++
Again, the original poster removed his
own code due to embarrassment.
- Forum Moderator
+++++++++++++++++++++
Last edited by davidfsauri on Mon Aug 19, 2019 7:40 am; edited 1 time in total |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Sorry |
Posted: Mon Aug 12, 2019 2:02 pm |
|
|
davidfsauri wrote: |
Error 51: Expecting Function Name
|
You get this error when you are missing the main() function.
In CCS, you must have a main() function. |
|
 |
javier.jimenez
Joined: 12 Aug 2019 Posts: 1
|
|
Posted: Mon Aug 12, 2019 2:18 pm |
|
|
Excuse Ttelmah
I have the similar problem with a code, and I don't understand what do you mean with "You are then trying to use this in printf, where a function name is expected", Could you help me? |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9480 Location: Greensville,Ontario
|
|
Posted: Mon Aug 12, 2019 5:31 pm |
|
|
other problem...
Quote: | i = (i/120)*2800; // corriente del secundario del sensor |
You've declared 'i' as 'int', which in CCS C is int8 or 8-bit, NOT 16-bit which I think you think it is.
The same holds true for other variables.
also
Quote: | #USE RS232(BAUD=9600, XMIT=3, RCV=2) |
xmit=PIN_A3 not XMIT=3 |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Aug 12, 2019 6:57 pm |
|
|
javier.jimenez wrote: |
What do you mean with "You are then trying to use this in printf, where a
function name is expected", Could you help me? |
Look at the CCS example file Ex_lcdth.c in the CCS Examples folder.
It shows this line:
Quote: | printf(lcd_putc,"\fCurrent Temp: %U F\nMin: %U Max: %U", current_temp,min_temp,max_temp); |
This line sends the output of the printf function to the lcd_putc() function.
This feature is an extension of the C language provided by the CCS
compiler. It's useful. You can send the output of printf() to any function
that accepts a character as input, such as lcd_putc().
Note that the Ex_lcdth.c file includes the lcd.c driver in it. This file has
lcd_putc() defined in it:
Quote: | #include <16F887.h>
#use delay(crystal=20mhz)
#include <lcd.c>
|
Ttelmah means that he is missing the #include <lcd.c> line, so lcd_putc
is not defined. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19872
|
|
Posted: Tue Aug 13, 2019 12:18 am |
|
|
and he has in his code:
int lcd_putc;
A variable called lcd_putc.... |
|
 |
madGambol
Joined: 19 Nov 2019 Posts: 2
|
Expecting function name |
Posted: Sun Jun 22, 2025 11:29 am |
|
|
If that message signifies that a main() is expected, why doesn't it say "Expecting main()" ??
That would be about 1000 times less mysterious and would instantly flag what the problem is for someone not yet clued into the "common knowledge" or lore around things like this.
 |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19872
|
|
Posted: Mon Jun 23, 2025 1:13 am |
|
|
Because the original code was removed, you are not seeing that it was actually
that he was calling printf, setup to use a print to a function, but was not
giving this a function name.
The point is the error is just saying that at the point involved a function name
is missing. This can be because what is there is not a function, or that it
gets to the end of the code without finding a main, or any number of other
missing functions.
The compiler does not attempt to solve this type of thing for you. It knows
you are doing something without a function name, so just says this.
The diagnostics in the compiler are generally very crude. I use a C syntax
checker if looking for what is causing a problem. |
|
 |
madGambol
Joined: 19 Nov 2019 Posts: 2
|
Error 51: Expecting Function Name vs +EXPORT |
Posted: Mon Jun 23, 2025 4:42 pm |
|
|
Can the messages the compiler emits be adjusted to fix this poorly descriptive message?
If the message means that a main is missing, that actually shouldn't be known until the link step. But if the compiler knows it's going to link this compilation unit because there was no "+EXPORT" option on the command line, the message should be specific so that the command line option can be added.
 |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19872
|
|
Posted: Tue Jun 24, 2025 7:19 am |
|
|
You would need to talk to CCS.
Understand (read the note at the tops), that this is a _user_ forum, not
CCS.
However it would need quite a large change to how the checking is done. It
basically scans simply through the code, checking that the things it
expects are where they need to be. The error comes when at a
location where it needs a function name, one is missing.
To distinguish that bit is 'main' that is missing, would need the checking
to look much deeper than it does at this point.
Some improvements to the syntax checking, would be worthwhile, but
it is CCS you need to ask for this. |
|
 |
|