This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C++ Compiler Problem ..



Hi,

I m working on AM335x SK. This is the simple Code i m working on:

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <stdint.h>
#include <ctype.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/ioctl.h>


#include "nfc_ioctl.h"

//*********Global Defines********************/
//
#define ERROR -1

//*********Global Variables******************/
//int sigtermed = 0;
int fd;			//File Descriptor '/dev/nfc'
//int retval;
FILE *TestFilePtr;	//File Pointer to <path_to>/ssid.txt


void my_signal_handler(int signum);

int main(int argc, char *argv[])
{

	//****Set Keyboard Interrupt handlers***/
	signal(SIGINT, my_signal_handler);
	signal(SIGTERM, my_signal_handler);
	signal(SIGQUIT, my_signal_handler);
	signal(SIGTSTP, my_signal_handler);

	TestFilePtr = fopen( "/usr/share/matrix-gui-2.0/apps/home_automation/ssid.txt", "wt+" );
	if (( fd = open( "/dev/nfc", O_RDWR, 0)) == ERROR) {
		perror("open");
		exit(ERROR);
	}


	ioctl( fd, SPI_WRITE, 1 );


	close(fd);
	return 0;
}

void my_signal_handler(int signum)
{
	printf("Caught signal %d\n", signum);
	fclose( TestFilePtr );
	close(fd);
	exit(signum);
}


8233.nfc_ioctl.h

When i compile this main.c file using :

/home/user/ti-sdk-am335x-evm-05.05.01.00/linux-devkit/bin/arm-arago-linux-gnueabi-gcc main.c -o main

every thing works fine ..

The Problem is that : i have to build a C++ Project !!

i m changing main.c to main.cpp when i use the same Compiler i got the Error :

user@user-desktop:~/Desktop/SPIexample/XXXXX$ /home/user/ti-sdk-am335x-evm-05.05.01.00/linux-devkit/bin/arm-arago-linux-gnueabi-gcc main.cpp -o main
main.cpp: In function 'int main(int, char**)':
main.cpp:88:26: error: 'ioctl' was not declared in this scope

I tried to build a new C++ Project with Code Composer with this Code: In the Cosole i see that it is using following to compile:

arm-arago-linux-gnueabi-g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"

arm-arago-linux-gnueabi-g++  -o "project 1"  ./main.o   

i got an error : ../main.cpp:14:16: error: 'ioctl' was not declared in this scope

so why does the Compiler don't know where to find this function when i m compiling C++ 


thnx best regards,

aly