| NanoGoner (26) | |
|
My file reads in part like this: ----------------------------------------------------------- /* Main.c for PC side of control fed to * AVR by UART/ RS232 */ #include <stdio.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <pthread.h> void *control_updater (unsigned char rs232_control[10][10]); void main(int argc, char **argv) { control_init(); ---------------------------------------------------- When compiled in AVI, CodeBlocks, the following error appears: ---------------------------------------------------- /home/Dev_Plat/Desktop/Control_Course/main.c --- line 20 --- error: expected ‘;’, ‘,’ or ‘)’ before ‘{’ token| ||=== Build finished: 1 errors, 0 warnings ===| ---------------------------------------------------- I have retyped the lines, and cannot find how to correct it. Can anyone guide me? | |
|
|
|
| doug4 (233) | |
|
Please post more of the file. If you use the code tags (they show up as "<>" in the Format box to the right of the input window), line numbers will show up. The main function must have a return type of int (according to the standards). Some compilers allow for a return type of void, but this is not good practice. And that does not seem to be the problem you are running into.When we can see more of the code and see which is line 20, maybe we can give you more help. | |
|
|
|
| NanoGoner (26) | |||
The complete Main.c is posted here:
There are numerous other files. The error message refers to the line 20 indicated. I changed the main type to int with same result | |||
|
Last edited on
|
|||
| doug4 (233) | |
|
I'm sorry. I don't see an error in this. I can only guess at things. I assume that the 7 missing lines (line 20 shows up as line 13) are comments or blank or something. Is there any non-comment lines that were omitted in your post? Interestingly, you changed your include from <pthread.h> to "pthread.h". Is there a possibility that you are using your own pthread.h file that has something declared incompletely?By the way, you control_updater function is declared to take an array of 10-char arrays, while it is defined to take an array of 8-char arrays. I don't think that's your problem, but it needs to be corrected. Also, I don't see the definition of rs232_control as seen by the body of main(). Could it be a global array whose definition got messed up somehow? Without seeing the entire Main.c, I can't be more specific. Have a happy new year. | |
|
|
|
| NanoGoner (26) | |
| I corrected those errors with the same results. The first 13 lines were titles and other non-operative comments. | |
|
|
|
| ne555 (4385) | |
|
> The first 13 lines were titles and other non-operative comments. Your first line has only a `/' that's causing your compiler to choke. You need to define rs232_control | |
|
|
|
| ne555 (4385) | |
|
You've got a `/' in the first line that is causing your compiler to choke. Also, you need to define `rs232_control' | |
|
|
|
| NanoGoner (26) | |
| I defined it as a 8x8 matrix, what else is needed?? | |
|
|
|
| jlb (170) | |||
What compiler are you using? What standard are you compiling to, C90, C99, or C11? I would start by commenting out everything except:
Make sure you add the return statement. If the program compiles then start uncommenting a line or two at a time and compile as you go. When the program stops compiling you may have found your problem. | |||
|
Last edited on
|
|||
| pogrady (525) | |
| I've found that Visual Studio 2010 doesn't like forward declarations very much. Try replacing your forward declaration of void* control_updater with the implementation. | |
|
|
|
| Disch (8615) | ||
waaaaat? | ||
|
|
||
| pogrady (525) | ||
Not sure if sarcasm or insinuation of my stupidity. | ||
|
|
||
| Disch (8615) | |
| It was actually confusion. I've never had such an experience with Visual Studio and I can't imagine why you'd think it would have a problem with such a fundamentally basic part of the C++ language. | |
|
|
|
| NanoGoner (26) | |||||
I'm using GCC in CodeBlocks I'm reposting the code with suggestions included and a new set of error messages. Getting this threading correct is tougher than I thought
Here are the error messages:
New issues are : I declared the rs232_cube in line 17, but it seems to think I haven't declared it, and that the previous declaration is in line 13, but there are no declarations for it in gameoflife.h. If I I do see that the declaration is faulty, by the error message in line 18, but after numerous tries have been unable to fix it. I've trieded the casting suggestion from kbw with and without the various changes in the declaration, all without improvement, but a variety of different error messages. The suggestion to comment out everything and uncomment a line at a time leads me to believe the problem is between lines 13 and 35. [/code] | |||||
|
Last edited on
|
|||||
| ne555 (4385) | |
|
> you need to define `rs232_control' >> I defined it as a 8x8 matrix No, you don't. Learn about scope | |
|
|
|
| jlb (170) | |||
Does your program still contain all these includes?
If so then you need to carefully investigate your headers. Look for simple things like a missing semicolon at the end of a class declaration etc. When dealing with errors the compiler tells you where it detects the error not necessarily exactly where the error is located. You start at that location and start back tracking until you find the problem. If not then where have you defined things like: control_init(); | |||
|
|
|||
| NanoGoner (26) | |
|
I checked the headers and found a missing " ; ". I now have one error message which I can't resolve: The function declaration in cube.h is: cube. h line 21: void cube_push (unsigned char data[CUBE_SIZE][CUBE_SIZE]); The Function Call in main.c: In the function int main(int argc, char **argv is: note: file main.c includes: line 9 #include "cube.h" (see code above) main.c Line 21: cube_updater(*rs232_cube) The function implimentation in main.c is: main.c Line 92: cube_updater ( (void *)rs232_cube) The error message is: main.c Line 92: error: expected declaration specifiers or ‘...’ before ‘(’ token| | |
|
Last edited on
|
|
| jlb (170) | |
|
What file is this error located in? Your compiler should tell you this information. Please post the complete error messages (all of the messages) exactly as they appear in your development environment. These messages have important information embedded within them to aid in locating and repairing the errors. Also in future don't remove pertinent information from your files when, for example in your last posts you left out your header file includes, you only showed "standard" headers. | |
|
Last edited on
|
|
| doug4 (233) | |
|
Also repost your file. The line numbers in this last past don't line up with the last file you posted, so they make no sense. If the titles in your last post are correct, then line 92 is wrong--it should be the same as the function declaration. Also, line 21 may or may not need a *. Of course, without the full code, that's only guesses.
| |
|
|
|
| NanoGoner (26) | |||
|
I've modified the description above to reflect the location of the various aspects of the function in question. Check the more complete code in earlier entries to get a better context if needed. The error message is the only error. I'm reposting the code in main.c
| |||
|
Last edited on
|
|||