简体   繁体   中英

Compile C++ file as objective-c++ using makefile

I'm trying to compile .cpp files as objective-c++ using makefile as few of my cpp file have objective code. I added -x objective-c++ as complier option and started getting stray /327 in program error( and lots of similar error with different numbers after /). The errors are around 200. But when I change the encoding of the file from unicode-8 to 16 the error reduces to 23. currently there is no objective-c++ code in the .cpp file but plan to add in future. When i remove -x objective-c++ from complier option ,everything complies fine. and .out is generated. I would be helpful if someone will tell me why this is happening and even a solution for the same Thanks in advance

example of my makefile

MACHINE= $(shell uname -s)


CFLAGS?=-w -framework CoreServices -framework ApplicationServices -framework CoreFoundation -framework CoreWLAN -framework Cocoa -framework Foundation

ifeq ($(MACHINE),Darwin)
  CCLINK?= -lpthread 
else
 CCLINK?= -lpthread -lrt 
endif   

DEBUG?= -g -rdynamic -ggdb 
CCOPT= $(CFLAGS)  $(ARCH) $(PROF)
CC =g++ -x objective-c++
AR = ar rcs
#lib name
SLIB_NAME=myapplib
EXENAME = myapp.out
OBJDIR = build

OBJLIB := $(addprefix $(OBJDIR)/... all .o files)


SS_OBJ := $(addprefix $(OBJDIR)/,myapp.o  )

vpath %.cpp path to my .cpp files



INC  = include files


subsystem:

     make all

$(OBJLIB) : |$(OBJDIR)
$(OBJDIR):
     mkdir $(OBJDIR) 


$(OBJDIR)/%.o:%.cpp 
    $(CC) -c  $(INC) $(CCOPT) $(DEBUG) $(CCLINK) $< -o $@


all:  $(OBJLIB) $(CLI_OBJ) $(SS_OBJ)
    $(AR)  lib$(SLIB_NAME).a $(OBJLIB)
    $(CC)  $(INC) $(CCOPT) $(SS_OBJ) $(DEBUG) $(CCLINK) -l$(SLIB_NAME) -L ./ -o $(OBJDIR)/$(EXENAME) 


clean:
    rm -rf $(OBJDIR)/*
dep:
    $(CC) -MM *.cpp

You have a stray × (multiply sign) outside of a quoted string. All C/C++ must be ASCII, except what is in a string.

Note: ASCII converted to UTF-8 is ASCII. If utf-16 then not quoted strings must be ASCII equivalent, supposing compiler supports utf-16. Also the to file formats may produce different code, differing in the strings produced.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM