Reputation: 24602
Do Objective-C or MATLAB/Octave have source file extensions besides .m
? I ask because I'm putting Hello World programs in a single folder and I can't have two hello.m
files.
Upvotes: 4
Views: 1688
Reputation: 32883
A workaround would be to use .mm
for Objective-C. .mm
is used for Objective-C++ source files and it is a superset of Objective-C so it should compile fine.
This is by no mean a clean solution. A much better way would be to reorganize your folder into subfolders as suggested by Ruddy Velthuis, or simply to call your source files hello-objective-c.m
and hello-matlab.m
.
Upvotes: 2
Reputation: 28806
The only way I see is to create subdirectories for each of the programs and put your files there. You can tell Obj-C to treat other extensions as Obj-C, but that would not solve the problem for the other programs.
Update
To compile any extension as Objective-C, use -x objective-c
on the command line or Select Objective-C from "Compile Sources As" in the target build settings. Default is "According To File Type", which means that only .m files are compield as Objective-C.
FWIW, there are many subtle differences between Objective-C++ and Objective-C. I myself would use subfolders to separate the .m files, as I already said above.
Upvotes: 3
Reputation: 124563
MATLAB cannot find files unless they have the .m
extension (very important!)
Now I know very little about Objective-C, I presume it's a superset of C (just like C++ is). If so, and similar to C/C++, you should be able to pass any file name as input to the compiler:
g++ -c myfile.m.txt
Upvotes: 0