Difference between revisions of "C Projects in Eclipse"

From DiLab
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
New Project setup process:
* Download [http://www.eclipse.org/downloads/ Eclipse CDT] - from the list choose "Eclipse IDE for C/C++ Developers".
* Download [http://www.eclipse.org/downloads/ Eclipse CDT] - from the list choose "Eclipse IDE for C/C++ Developers".
* Unarchive and run downloaded Eclipse
* Unarchive and run downloaded Eclipse
Line 22: Line 23:
* 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. Very useful to check, where a variable is initialized and modified
* 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 modified
* Ctrl+PageUp, Ctrl+PageDown - switch to previous/next source window
* Ctrl+W - Close window


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.

Keyboard shortcut configuration: Window > Preferences > General > Keys. For Mac Preferences are under "Eclipse", not under "Window".

If you use a compiler, which is not in your environment path, you can set PATH variable under Window > Preferences > C++ > Environment > Add...

Latest revision as of 16:16, 23 November 2009

New Project setup process:

  • 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 modified
  • Ctrl+PageUp, Ctrl+PageDown - switch to previous/next source window
  • Ctrl+W - Close window

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

Keyboard shortcut configuration: Window > Preferences > General > Keys. For Mac Preferences are under "Eclipse", not under "Window".

If you use a compiler, which is not in your environment path, you can set PATH variable under Window > Preferences > C++ > Environment > Add...