I'm using SSH Secure Shell to connect to a Linux machine ... when I try to run the compiled code I have, I keep getting these errors ...
./p2.c: line 5: syntax error near unexpected token `('
./p2.c: line 5: `void *printMessage( void *thread_id );'
here are the first few lines of the code ... -
-
#include <stdio.h>
-
#include <stdlib.h>
-
#include <pthread.h>
-
-
void *printMessage( void *thread_id );
-
-
int main ( int argc, char *argv[] )
-
{
-
...
-
-
I compiled this code using "gcc -pthread p2.c"
then, tried to run it using "./p2.c"
but get that error
the program deals with threads, but I don't think that has anything to do with it. I'm don't have much experience with Linux, and have no clue why I keep getting this error. Any help would be appreciated.
4 8304
I'm using SSH Secure Shell to connect to a Linux machine ... when I try to run the compiled code I have, I keep getting these errors ...
./p2.c: line 5: syntax error near unexpected token `('
./p2.c: line 5: `void *printMessage( void *thread_id );'
here are the first few lines of the code ... -
-
#include <stdio.h>
-
#include <stdlib.h>
-
#include <pthread.h>
-
-
void *printMessage( void *thread_id );
-
-
int main ( int argc, char *argv[] )
-
{
-
...
-
-
I compiled this code using "gcc -pthread p2.c"
then, tried to run it using "./p2.c"
but get that error
the program deals with threads, but I don't think that has anything to do with it. I'm don't have much experience with Linux, and have no clue why I keep getting this error. Any help would be appreciated.
This is not a Linux issue, this is a C issue. Look at your function parameters. You are attempting to pass a void *thread_id . A pointer to a void. Since void is used to specify no parameters it's getting confused when you try to send it a thread_id.
So the question is - what is the type of the thread_id. When you declare it in your main what type is it?
I don't think it has to do with the type. I tried some different things out ...
I kept the same header files, made a simple function that takes an INT as its only argument and returns an int ... and in main, all I did was pass an int and get it's value back. I got the EXACT SAME ERROR.
So, I ran the same code again, but took out the <pthread.h> header file, and it compiled fine.
This is why I still believe it may be a Linux issue. I may be compiling it wrong, I don't know. I usually use "gcc -o programName programName.c", but I think I need to use "gcc -pthread programName2.c" to compile a program using pthreads.
I'm still lost, and I really do appreciate the help.
Dang, sorry about that. I think that would have been an issue anyway, but there is another issue. If you look at the error - the problem isn't with the argument, it's with the open parentheses. Or, what's right before the parentheses.
./p2.c: line 5: syntax error near unexpected token `('
./p2.c: line 5: `void *printMessage( void *thread_id );' -
void *printMessage( void *thread_id );
-
Why are you using a pointer for printMessage()? Try removing the * and see what that does.
PS - you do have the definition of this somewhere, right?
hey, thank you for the responses. Yes I do have the function defined elsewhere :) I actually never write code like that, but I separated the declaration from the definition trying to pinpoint the problem.
Anyway, I just figured out the problem. It was the way I was compiling. I had to use "gcc -o p2 p2.c -lpthread" to get it to compile right. I had used a ton of combinations of that, but never exactly that. Works perfectly now.
By the way, I had that function as a function pointer because where it's taken in as an argument in "pthread_create", it's looking for a pointer to a function. So, anyway, the code itself was okay.
Again, thanks for the replies, I appreciate the help.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Janwillem Borleffs |
last post by:
Q: I'm getting an unexpected $ or $end parse/syntax error, what's causing
this?
A: This is caused when an expression is started with an opening brace, but
the closing brace is omitted.
...
|
by: Bob Stearns |
last post by:
The statement:
merge into nullid.animals_et_in t1 using is3.animals t2
on t1.sire_assoc=t2.assoc and t1.sire_prefix=t2.prefix and
t1.sire_regnum=t2.regnum
when matched then update set...
|
by: r.nikhilk |
last post by:
Hi,
Currently, we are porting C++ applications from 32 bit to 64 bit on AIX
platform. (The current version of AIX is 5.3 and xlC verison is 8.0).
We are able to compile the applications by...
|
by: Manuel |
last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using
devc++.
So I've imported the glut32.dsp into devc++, included manually some
headers, and start to compile.
It return a very...
|
by: lisa |
last post by:
I have an XML file that starts like this:
<?xml version="1.0" encoding="ISO-8859-1"
xmlns:fn="http://www.w3.org/2005/xpath-functions"?>
<Authors>
<Author>
<ID>2</ID>...
|
by: GotDotNet? |
last post by:
I'm trying to insert data from one table to another on sql server via C#.
here is my syntax:
insert into tableA (CustOrderNumber, custName, custState, CustCity) SELECT
('" +...
|
by: bhunesh |
last post by:
hey ,
i m getting error listed below plz help me
/virtualHosts/beta.myiris.com/htdocs/commodities/commd_admin/CRONJOB/new_cronjob/new_mcx.pl: line 14: syntax error near unexpected token...
|
by: FightClubDiego |
last post by:
Hey.. I've been working on these sign up / log in forms for my new Game Site, and everything else in the game works but the registration!! I keep ketting the unexpected $end and Im tired of it! Here...
|
by: nvr |
last post by:
Hi all
I am doing the socket programming for the client side. but the code is not compiling and i am getting the below error
./Clientsend.c: line 11: syntax error near unexpected token `('...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| | |