I have made a mistake to change the .h file for some reason. And I do the #define CPU_ONLY 1 in the file, but I forgot its name.
Now I come across this problem when I make caffe test in terminal
./include/caffe/util/device_alternate.hpp:4:9: warning: 'CPU_ONLY' macro
redefined [-Wmacro-redefined]
#define CPU_ONLY
^
<command line>:6:9: note: previous definition is here
#define CPU_ONLY 1
^
1 warning generated.
How can I find the .h file I had changed, and I have searched in finder on MAC OS yet.
Related
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).
So, way back in January, I went here:
http://emacsformacosx.com/
I downloaded Emacs and have been using it on my Mac and I like it. I've started trying to get into Elisp programming. To learn more, I'd like to look up some functions. So for instance I do:
C-h f
and then type "scroll-down"
This gives me the following text:
>scroll-down is an interactive built-in function in `window.c'.
>
>It is bound to <kp-prior>, <prior>, C-1, C-x C-1, M-v.
>
>(scroll-down &optional ARG)
>
>Scroll text of selected window down ARG lines.
>If ARG is omitted or nil, scroll down by a near full screen.
>A near full screen is `next-screen-context-lines' less than a full screen.
>Negative ARG means scroll upward.
>If ARG is the atom `-', scroll upward by nearly full screen.
>When calling from a program, supply as argument a number, nil, or `-'.
And the text "window.c" is a link. So I click on the link and I get:
find-function-C-source: The C source file window.c is not available
I'm getting this error a lot while doing a lot of different things. Where do I find the right path, and how do I tell Emacs what that path is?
I did just recently install some ELPA packages, so maybe one of them is causing some chaos?
The variable source-directory will point to the location where the C sources are. If you have a separately downloaded copy, you'll have to point this variable to that directory.
Most packagers don't include the sources, or split them off into a separate package. Install the sources (and maybe tweak an init script to tell Emacs where you put them, if it's not the default location. The pertinent variable is find-function-C-source-directory).
If you didn't manually build Emacs from the source code and patch the C source code, value of source-directory or find-function-C-source-directory would be wrong.
You can manually download Emacs source code, unpack it somewhere and set above two variables accordingly like following
(setq source-directory "/path/to/your-emacs-repo")
;; OR
(setq find-function-C-source-directory "/path/to/your-emacs-repo/src")
GNU Emacs source code and development is hosted on savannah.gnu.org. You can find all the tags here and download the one that matches your M-x emacs-version.
I've got a large Xcode project which has a few dozen NSLogs, some commented out.
The find/replace in Xcode has a regular expression option, so how could I make it comment out all active NSLogs, in a way which another find/replace can turn them back on again. So, the initial code is:
//NSLog(#"one");
NSLog(#"two");
becomes, after regex find/replace:
//NSLog(#"one");
//**NSLog(#"two");
which which turned back on becomes:
//NSLog(#"one");
NSLog(#"two");
There's a much better solution. Just put this in your prefix.pch file:
//disable logging when not in debug
#ifndef DEBUG
#undef NSLog
#define NSLog(args, ...)
#endif
That will disable NSLogs when your app is not in debug mode. That way you don't have to actually remove them from the code, but they'll have no performance impact.
In case you're wondering how it works, it redefines the NSLog() function as blank when the DEBUG macro is not defined. By default DEBUG is defined only for debug projects. You can change it to be toggled on and off in a different way if you prefer by just replacing the first line with #if SOME_OTHER_CONDITION.
A better solution for this would be to use a macro such as DLog which you could control using a debug (or your own compiler flag). Check this link or this
I have following macro in my PCH file.
#ifdef DEBUG
#define MYLOG(...) NSLog(__VA_ARGS__)
#else
#define MYLOG(...) MYSERVERLOG(MYObject.enableLogging, __VA_ARGS__)
#endif
#define MYSERVERLOG(iLog, ...) iLog ? NSLog(__VA_ARGS__) : TRUE
Now, no matter if I put DEBUG=0 or DEBUG=1, it always go in first clause. But if I use "if" instead of "ifdef" for DEBUG in PCH then it works fine but then I get warnings on all my MYLOG statements saying "Expressing results unused".
How can I get rid of this situation?
I am guessing you only get the warning if DEBUG=0. The problem is that, after running through the preprocessor, the compiler sees code like this:
...
MYObject.enableLogging ? NSLog(#"your log",...) : TRUE;
...
The compiler is fine with letting you ignore the results of a function, assuming that the function did whatever you wanted and the result isn't useful. However, when you go through the trouble of calculating a value in your code with the ternary operator, it expects that you want the result of that calculation. If you know that you will never use the result of this macro, you can cast it to void to ignore it:
#define MYSERVERLOG(iLog, ...) ((void)(iLog ? NSLog(__VA_ARGS__) : TRUE))
If you might use the results of the macro, then you will have to do the cast every time you use the macro and ignore the result, or live with the warnings. In this case, you should still put parentheses around your macro to avoid possible problems.
#define MYSERVERLOG(iLog, ...) (iLog ? NSLog(__VA_ARGS__) : TRUE)
if you do a
#define DEBUG 0
OR if you do a
#define DEBUG 1
the "DEBUG" macro is defined so...
#ifdef DEBUG
will always be true since DEBUG is defined.
If you want to get into the 2nd clause, you will have to make sure the macro is not defined AT ALL (i.e. Delete the macro or comment it out).
I always open three windows when writing C code like this:
|
| 2
1 |_____
|
| 3
|
Window 1 is used for code writing, window 2 is used for cscope, and window 3 is used for header file quick reference.
When I press in cscope window to show source, I want Emacs to display .c files always in window 1 while .h files in window 3, is there any possible solution?
Many thanks for your reply.
Take a look at the answer to a similar question. The key is to use the variable: special-display-regexps. It's nearly a drop-in solution, only you choose the window based on the extension (as opposed to not choosing a window).