Difference between revisions of "C Projects in Eclipse"

From DiLab
Jump to: navigation, search
Line 20: Line 20:
* F3 or Ctr+Left click on a function, variable, macro - Open Declaration - go to its declaration/definition. The definition outline will be displayed automatically, if you hold mouse over a function/variable/macro name.
* F3 or Ctr+Left click on a function, variable, macro - Open Declaration - go to its declaration/definition. The definition outline will be displayed automatically, if you hold mouse over a function/variable/macro name.
* Ctrl+H - workspace wide search. Choose "File search". Type in your keyword and file pattern (I use "*.S, *.c, *.h" to search C source/header and ASM files). To avoid annoying C++/Task search, I choose "Customize"in the Search window and uncheck all the unnecessary alternatives, leaving only "File Search" checked.
* Ctrl+H - workspace wide search. Choose "File search". Type in your keyword and file pattern (I use "*.S, *.c, *.h" to search C source/header and ASM files). To avoid annoying C++/Task search, I choose "Customize"in the Search window and uncheck all the unnecessary alternatives, leaving only "File Search" checked.
* Ctrl+Shift+G on a variable/function - Open Call Hierarchy - show all places where it is used/called.
* Ctrl+Shift+G on a variable/function - Open Call Hierarchy - show all places where it is used/called. Very useful to check, where a variable is initialized and changed


All these commands are also available in the context menu - right click and choose it from the menu.
All these commands are also available in the context menu - right click and choose it from the menu.

Revision as of 17:25, 22 November 2009

  • Download Eclipse CDT - from the list Choose "Eclipse IDE for C/C++ Developers".
  • Unarchive and run downloaded Eclipse
  • Close "Welcome screen", if you're running Eclipse for the first time
  • Choose File > New > C Project
  • Type in a name, for example, lab03
  • Uncheck "Use default location"
  • Browse you lab root folder as Location
  • Choose "Makefile Project > Empty project" as Project type
  • Press "Finish"
  • A New project folder will appear on the left side, right click on it, properties
  • C/C++ General > Paths And Symbols > GNU C++
  • Add ... > Workspace
  • Choose your lab project root folder (lab03), OK, OK, OK

Now you should be able to work with your project.

Keyboard shortcuts worth knowing (On MacOS Ctrl must be replaced by Cmd for most of the shortcuts):

  • Ctrl+B - build your project. Check Console window for error messages
  • Ctrl+Tab - switch between source and header files (.c and .h)
  • F3 or Ctr+Left click on a function, variable, macro - Open Declaration - go to its declaration/definition. The definition outline will be displayed automatically, if you hold mouse over a function/variable/macro name.
  • Ctrl+H - workspace wide search. Choose "File search". Type in your keyword and file pattern (I use "*.S, *.c, *.h" to search C source/header and ASM files). To avoid annoying C++/Task search, I choose "Customize"in the Search window and uncheck all the unnecessary alternatives, leaving only "File Search" checked.
  • Ctrl+Shift+G on a variable/function - Open Call Hierarchy - show all places where it is used/called. Very useful to check, where a variable is initialized and changed

All these commands are also available in the context menu - right click and choose it from the menu.