Badly Placed ()'s

Hey guys,

This is my first post so bear with me...

In Linux I am writing the simplest c++ program just to make sure everything can execute before writing more advanced code. I am simply trying to run a c++ program that writes output to the screen however when I run the program, the same error comes up "Badly placed ()'s".

Here is my program fork.cpp:

#include <iostream>
#include <string>
#include <sys/types.h> // certain libraries included for later code, more specifically using a fork command
#include <unistd.h> // that I am also having trouble with
#include <stdlib.h>

int main ()
{
cout << "Hello World";
return 0;
}

The program is included in a Makefile I have so I compile with "make fork.cpp" then run with ./fork.cpp

***I have tried eliminating/moving the parenthesis after "int main" and still no help. I have also tried adding shell-script headers, more specifically the shell I am currently running in (TCSH). Any suggestions?

Just realized there is a *nix section of the forum so I am posting there too. Not sure if I can move the topic completely to *nix forum?


Last edited on
Please copy and paste the full log including that error.
Try using borune again shell (bash).

The program is included in a Makefile I have so I compile with "make fork.cpp" then run with ./fork.cpp


Are you sure that the executable created by your makefile is the same name as your actual code name. Because it seems that if you named the executable the same name as the actual file itself, this might be what your problem is.

try this:
g++ -Wall -Wextra -o unique_exec_name_here fork.cpp

then run using ./unique_exec_name_here
The program is included in a Makefile I have so I compile with "make fork.cpp" then run with ./fork.cpp

I've never seen this way of using make. Isn't it make -f makefile_name_without_extension usually?
EDIT
Uh yeah, I just realized that is the way you tell make to execute a specific target, I got confused by the fact that the file had an extension
Last edited on
If you have multiple files you need to compile in your makefile and you just want to compile one of then, you can specify the name of the file. So you can also do make -f make_file_name fork.cpp. Note you only need to do this if your makefile name is not 'makefile' or similar irrespective of upper/lowercase. Usually you just run make and the make command will find a file with the name 'makefile' and run whatever is in there
int main(int nNumberofArgs, char* pszArgs[])

If this works...
greenleaf800073 wrote:
int nNumberofArgs, char* pszArgs[]
Kill it with fire

greenleaf800073 wrote:
int nNumberofArgs, char* pszArgs[]
Kill it with fire


Why
Topic archived. No new replies allowed.