We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
void PWM_Config(uint8_t TIM_PERIOD, uint8_t TIM_PULSE) { . . . } int main() { TIMConfig(); // THIS LINE SHOWS AN ERROR . . . }
ERROR LIST:
main.c(251): error: #165: too few arguments in function call PWM_Config();
BUT, If I write the program below, there is an no error
void PWM_Config() { . . . } int main() { TIMConfig(); // THIS LINE SHOWS AN ERROR . . . }
KINDLY HELP!
Wher is problem? in first example you have function with 2 parametrs TIM_PERIOD and TIM_PULSE and without return value (void front function name). you must call
TIMConfig(50,5); // THIS LINE SHOWS AN ERROR
. Where TIM_PERIOD=50 and TIM_PULSE=5
Second example is declared as function without paremeter and without return parameter.
void PWM_Config(void)
Any reason the functions have different names?
The required syntax is pretty well defined in the language documentation, it doesn't change just because it is inconvenient for you. And the compiler is pretty good at spotting these types of error.
In this thread, the same name is used.
http://www.keil.com/forum/60845/
Not sure if this is a real question, or if the teacher have handed out a number of incorrect files and expects the students to explain if the code is ok or not - and what is wrong.
It just seems to far-fetched to wonder why the compiler would not like it if the function is called without any parameters - or using a completely different name.