How can I set different styles of code depending on the file type in Eclipse?

We use CMake to manage our builds and have a fairly large project consisting of almost everything we need to build a software base for our embedded platforms, with the exception of the toolchain. When building a CDT project with CMake, it puts everything in one large project rather than breaking it down into separate projects based on the CMake specification.

Our problem is that we have C and C ++ code in the project and we have different code styles for those languages. I haven't been able to figure out how to tell Eclipse to select a code style based on the file type and not the project, and this makes Eclipse very difficult for us to use as you have to remember to manually switch the style for the entire project if you want to switch from working in C to a C ++ project or vice versa.

Is it possible to set the code style based on the file type and not just the whole project?

0


source to share


1 answer


You can use the advanced "link to a folder in the file system" option in the new folder dialog.

Basically create a build-c project and then create a new folder inside which the build is called and link to the build source files located elsewhere. Then for the build-c project, you can change the code style to something other than the build project.



If this is confusing, you can create another project named build-cpp and do the same (create a folder named build and link to the actual location of the build source files). You can then use filtering projects with working sets (one working set that includes a build-c project and another working set called build-cpp).

Since the folders in both projects are simply referenced to the original location of the assembly files, you don't need to worry about multiple copies between projects. However, you could only check the files in the main assembly project. It also still requires the user to manually switch working sets from c to cpp depending on what they are interested in changing.

+1


source







All Articles