Configuring default compiler settings in Eclipse IDE for C/C++ - eclipse

I am very new to Eclipse and I am currently running Eclipse 2022-03 with CDT 10.6.1 installed. I've been trying to setup the default C/C++ compiler flags for all projects but I do not understand how to.
I do know that configuring the compiler settings per project is possible through Project Properties -> C/C++ Build -> Tool Settings Tab in which many settings can be configured.
My question is, instead of doing it manually one by one for each new project, is it possible to configure the default compiler settings for all new C/C++ Managed Build projects?
I have tried adding the compiler flags in Window -> Preferences -> C/C++ -> Build -> Settings -> Discovery Tab and editing the command to get compiler specs but it seems to do nothing.
As I side note, I create my projects using New -> C/C++ Project and choosing either the C or C++ Managed Build Template.

Related

Minimal run/debug configurations for eclipse plug-in projects

I am working on an eclipse plug-in project. Running/debugging the plug-in project in a standlone Runtime Workbench is a routine work. However, the runtime workbench launches and responds slowly, because my eclipse edition contains too many plug-ins.
Problem: How can I create a minimal run/debug configuration without unnecessary plug-ins?
My trial: The option Run As -> Run Configurations -> Plug-ins -> Launch with plug-ins selected below only lists too many plug-ins to choose from. I am not sure what are required and what are unnecessary.
I try Deselect All -> Add Required Plug-ins, but it causes errors and fails to launch the runtime workbench.
The post: Eclipse minimal configuration for plug-in deployment seems related but it is focused on product deployment and I don't how can it be applied to my situation.
Source: You can find the plug-in project at https://github.com/hengxin/Eclipse-Plugin-Favorite-Demo. It simply contributes a QualityEclipse -> Favorites view.
What if after Deselect All -> Add Required Plug-ins, you check your application plugins and then Add Required Plug-ins ? There might be few plugins to add manually though

Getting "Project facet Java version 1.8 is not supported." in Eclipse Luna

I am using up-to-date Eclipse Luna which should be ready for Java 8. However when I choose to create a new server with Tomcat 7 and click Next, in the Add and Remove screen I can't move my project because "Project facet Java version 1.8 is not supported." What is the problem and how can I fix this?
I solved the problem. Go to Project Properties -> Project Facets -> Runtime -> New -> Add a tomcat server and in JRE select JRE1.8.0_XX.
Did the work for me
In eclipse you can change the java version from your tomcat, see picture:
That is because you just changed your JRE location in the workspace property, which TOMCAT relies on.
Please reset your tomcat property accordingly again:
windows -> preference -> server -> Runtime Environments. To the right of Runtime Environments, you should see the servers. Remove Tomcat 8.0 and add Tomcat v9.0. Rebuild project.
You can remove and create it again, or just update it.
It is because Java version in your Project Facet is 1.8 make it 1.7.
Go to Project Properties -> Project Facets
and on right side checkboxes, select java checkbox(It might be already selected) and select the version as 1.7 from dropdown.
Window Menu -> Preferences
On the left, expand the Server and click Runtime Environments
Edit Server Runtime Environment. Choose JDK 1.8
Dont forget rebuild your project.
Actually I just wanted to add to the knowledge here. I often run into this problem. The thing that solves it for me is to actually change the Compiler compliance level.
Do this :
Right click on project -> Properties
Click on Java Compiler Tab
UNCHECK Enable Project Specific Settings, then click on the configure workspace settings... link and make sure your compiler compliance level is set to the preferred java version your runtime cannot support.
Once done, rebuild your project this may clear the problem.
This might be a problem with the jdk as well. I changed my jdk version from jdk1.8.0_65 to jdk1.8.0_25. IDE version that I have is Version: Luna Service Release 2 (4.4.2).

How to show unused use's in Eclipse for PHP?

Some of use's is not required and I want my Eclipse ide to show this as warning.
Which setting sholud I change?
You can use the free tool PHP-CS-Fixer. It includes the UnusedUseStatementsFixer.php that will detect and remove all unused use statements.
It is also contained in the Eclipse plugin PDT Extensions. Once installed, you can start it by right-clicking the PHP file in Eclipse. Options can be set at:
Eclipse -> Preferences -> PHP -> Code Style -> CS Fixer
That plugin works with Eclipse Kepler (4.3).

Using both jdk 1.6 and jdk 1.7 for different projects in Eclipse

I am using Eclipse with JDK 1.7. My previous projects are developed in java 7 and JDK 1.7.
Now, I want to build a new project under JDK 1.6 in Eclipse. Is it possible to do that so that some projects are based on JDK 1.7 and some others are based on JDK 1.6 without conflicts?
If this can be done, please let me know how to do it step by step.
Update:
My default JDK is 1.7. I created a new project that is based on jdk1.7 by default. And then I go to the property of this project, and then java compiler, then change the compliance settings as the image shows below. But there is some error occurred. What could be the reason causes this error?
The following is the "problem" view
After some research, I have solved this problem. please see the reference about how to fix the facet version.
You can set overall workspace properties to use one version of Java and set individual project properties to use another.
To set overall workspace properties, click on Window > Preferences, then navigate to Java > Compiler.
To set project properties, right-click on the project and select Properties. Navigate to Java Compiler and check "Enable project specific settings"
You can choose from among the installed JREs for either setting. To tell Eclipse about a newly installed JRE, you can open the workspace preferences and navigate to Java > Installed JREs and then click the "Add" button.
You can change the JDK used by project under Project properties(alt+enter)-> Installed JREs. Also Debug Configuration is your friend. You can set what JDK to use when launching/running an app/program in Eclipse.
This can be done for an Eclipse Run Configuration. You may define multiple such configurations, each of which will reference a "main class" in one of your projects.
In Window -> Preferences -> Java -> Installed JREs define a location for each JRE/JDK.
For a given Eclipse project:
right click on the project, select Properties -> Java Compiler, override and set compiliance level settings.
Check Use compliance from ..., visit the Java Build Path and be sure you have a JRE Library set that matches the desired compliance level.
For a given Eclipse Run Configuration: Run -> Run Configurations... -> Java Application, select an old or create a new configuration, select the JRE tab and specify the Runtime JRE.

OSGi with Eclipse: How to hide eclipse Bundles?

Using Eclipse for OSGi Development is great.
Eclipse comes with cool auto completion features, thats also very helpful in OSGi.
By default Eclipse will suggest Bundles/Packages that are not created by myself but are available in Eclipse.
So my Question is how can i avoid that ? I just want to have my own bundles in these suggestions or auto completions. Is this possible ?
The set of visible bundles is controlled by the "target platform" that you define. By default, it points to self, so you see various bundles present in the Eclipse installation.
See Window -> Preferences -> Plug-in Development -> Target Platform