I would like to index every #ifdef and #else blocks in my C/C++ source files with my CDT indexer 8.0.2 on Eclipse indigo on Ubuntu.
Adding symbols wouldn't work since it would not cover #else blocks
Is there any way that I can force Eclipse CDT to simply ignore the #ifdef and #else blocks? like other indexers do ( like emacs cscope )
I've been searching for days and didn't find any good solution.
I have a really big amount of code and would better not edit it to remove #ifdefs even temporary.
The short answer is no. The CDT pre-processor doesn't work that way. It follows the correct semantics, meaning it only parses one branch of a #ifdef. Emacs may be going into each branch but its not doing an analysis that's as correct or complete as CDT.
Your only option is to set up multiple build configurations that are configured to parse each branch. Then you can switch build configurations when you want to work in the different branches. This is far from ideal though because it can be time consuming to set up and it will trigger a re-index every time you switch. (Also you have to configure it to do the re-index, go to Window > Preferences > C/C++ > Indexer and select "Use active build configuration")
Note that the CDT parser will parse inside of inactive #else branches just to find declarations to show in the outline view.
Related
Every time I start vscode, OminiPascalServer.exe start to use 35 to 50% of CPU process.
This appears not only in my computer, but with every person I know who use this extention.
Exist some configuration to fix it?
Thanks!
This usually happens at the start as OmniPascal probably need to scan through the entire workspace. So one way to quicken the process is to reduce the amount of things it need to scan.
This is how I do it and I notices a drastic improvement:
Create a new VSCode workspace that only focuses on Pascal files
In your VSCode workspace, add relevant folders
In Settings > Files > Exclude, exclude all irrelevant items in your Pascal project. (I don't know if this actually matters, but it seems to help)
In the case that you want to add external library, rather than adding them as part of your workspace, you can add them in Settings > OmniPascal > Search Path. You might also need to change the Symbol Index to select "searchPath"
This might seem to be a very very stupid question.
But for the past few years I have been using vim and cscope on the terminal, with some screen to make life a bit bearable.
I have just started to learn emacs and it is much more satisfying to use it.
Problem using emacs:
Every time I do M-x find-c-symbol, I get a new buffer with a bunch of files, but I don't know how to open the file at the exact line number.
I googled a lot and found this to open file under cursor: M-x ffap
but this opens at the first line. Can some emacs expert help me??
Thanks
I've got both Emacs 23.x and 24.x installed, both setup with working cscope and xcscope installs. Neither has a "find-c-symbol" function, but there is a "cscope-find-this-symbol", which is what I assume you're actually using.
I'm going to assume you're using a GUI version, and not the text-only version, and that you're actually getting the *cscope* buffer automatically being opened and created (since that's what it sounds like from your description).
For a simple search, I'll get results that look like this:
Finding symbol: debug
Database directory: /home/user/emacs_tags/modular/
-------------------------------------------------------------------------------
*** /home/user/code/modular/frontend/common/controller.test/src/MainTest.cpp:
<global>[73] #ifdef debug
-------------------------------------------------------------------------------
Database directory: /home/user/emacs_tags/rrsdk/
-------------------------------------------------------------------------------
*** /home/user/code/rrsdk/fs/apps/busybox/src/shell/ash.c:
<global>[303] #define debug optlist[15 + ENABLE_ASH_BASH_COMPAT]
*** /home/user/code/rrsdk/bootloader/u-boot/src/board/mcc200/auto_update.c:
<global>[53] #undef debug
<global>[55] #define debug(fmt,args...) printf (fmt ,##args)
<global>[57] #define debug(fmt,args...)
-------------------------------------------------------------------------------
Search complete. Search time = 22.44 seconds.
Assuming your results look similar (they should), there are two multiple target areas in the result. Each file line (the lines starting with ***) is a target to the start of that file. Each individual result is also a target area. If you click on one of the lines that lists a specific match (or put your cursor on it and press enter), it will attempt to jump to the specific line matching the result. If it's not jumping to the specific line correctly it usually means your code has changed since the last time the cscope index file was generated.
I'm not sure how you're using the cscope tool, but you can setup xcscope to auto-index on every change to keep the file up to date, but it really only works for smaller code bases where you can keep the cscope.out files in the top level directory and provide it with a full file list for the files to index. Most people I've talked to use the cscope tool by hand in an external script to manually index/re-index every once in a while and then just interface to the existing cscope database(s) using the emacs tools (mine takes about 4 hours to generate the cscope database for a project that includes the Linux kernel as a sub-part).
What I mean is this:
If there are errors in any of the source files, Eclipse would in very good fashion highlight files that have problems. This is something I've been missing when I use Vim. So my question is, are there any vim plugins that replicates this behavior? some extension for NerdTree maybe?
Vim has a different mechanism called the quickfix list. Basically you run the :make command which depending on your buffer runs what ever 'makeprg' is set to. The results get put into the quickfix list. You can then use :cnext, :cprev to move between the errors. You can use :cnfile and :cpfile to go to the next and previous file in the list. You can also view the list via :copen.
I recommend using Tim Pope's excellent vim-unimpaired plugin which provides some nice mappings like: [q and ]q, mappings to move through the quickfix list.
For more help see:
:h :make
:h 'makeprg'
:h quickfix
:h :cn
:h :cnf
I am using emacs 23.3
I heard that emacs 23.3 include cedet by default
but how can I use them? how should I change my ".emacs" file for ..
function parameter hint
(when I type "malloc(" then parameter hint arise somewhere)
auto complete menu
(when there are variable "qwer", "qwert", and "qwerty" and when I type "qwe" then those 3 selectable hint arise somewhere)
when I edit c or cpp file?
(and.. any suggestion for cedet feature?)
Are you asking as someone using an old CEDET distribution, or someone new to CEDET? I'll assume the later.
First, you need to enable semantic with this in your .emacs:
(semantic-mode 1)
next, if your project is particularly large (more than 1 directory full of files) you will need to enable EDE.
(global-ede-mode 1)
and figure out what kind of project to use. Your project might be auto-detected if it is one of the common ones, otherwise you should create one of type ede-cpp-root to just wrap that directory, or try enabling the generic project types that use a Makefile, scons or cmap, or with:
(ede-enable-generic-projects)
Generic projects can sometimes get in the way, so they are disabled by default.
You would then need to enable the idle summary mode:
(global-semantic-idle-summary-mode 1)
Look in the Development menu for other options.
I want to force the current execution line to a specific line in the same function, possibly skipping intermediate lines. All my old school debuggers had this feature, but I can't find it in eclipse. Is there a way to do it without changing code?
The first two answers seem to miss the topic, unless it is me not understanding the question.
My understanding, a feature I searched myself, is that you want to skip a number of lines (when stepping in code) and set the program counter (to take assembly vocabulary) to the given line. It might be interesting to skip some costly object creation, see some error situations, etc. I used to do that in Visual Studio (C or C++ code).
I haven't found that in Eclipse, nor in NetBean. It might be a limitation of JVM, or an enforcement of some policy...
The Run to line command execute, of course, all lines between the current execution position and the designated one.
I too have long sought this feature, and "Run to line" is not the same thing.
This may well be a limitation of the JVM. Java does not implement goto, though it does have jump statements, like break and continue. Those are at the block level however. If this is a JVM limitation, my guess is that it is more likely due to the security architecture. Tight control of the program counter is debilitating for interlopers, like viruses -- and sadly debuggers.
I think that is not possible in Java. The only feature that allows you to "step back" is using "drop to frame", which takes you back to the first instruction of the current frame. At least I haven't seen any debugger with this specific functionality, but I haven't been able to find on the net why is it so...
I know the debugger in Visual C allows to change to pointer. I will keep on searching, maybe at least we will know why is like this, but it seems to be some kind of design limitation.
Feature request saying it is not possible
In https://bugs.eclipse.org/bugs/show_bug.cgi?id=287795 (credits to Amitd) Darin Wright says it is a limitation of the underlying Java debugger:
Currently, this is not possible with the Java debugger as the native debug interface does not provide the ability to move/set the program counter arbitrarily.
C / C++
CDT supports it however (tested on Neon, Ubuntu 14.04). Right click on the line you want to go to, and select either:
"Move to line": jump to line and break there
"Resume at line": jump to line and continue execution from there
This also serves as further evidence that there is an underlying Java limitation, as Java tends to be more feature rich in Eclipse, and those menu entries are not present in Java next to "Run to line" (which does not skip execution of lines).
This test program prints 0 if you jump the line i = 1:
#include <stdio.h>
int main(void) {
int i;
i = 0; /* Break here. */
i = 1;
printf("%d\n", i); /* Jump to here. */
}
"Run to line" appears to need the program to be running and in a paused state to use. The other option is to set a breakpoint for that line when running in debug-mode.
Double-click far-left vertical bar in the source pane on the same line to add a breakpoint; or,
Select the line and go to Run > Toggle Breakpoint.
At least, this is in Eclipse 3.3.2.