I used AutoHotKey recently, where I made a hotstring which would create a piece of code so that I can increase my productivity.
Here is the hotstring:
::basic::#include <iostream> int main(){}
But the output is:
#include <iostream> int main()
This script didn't include the curly braces I reqiured.
So, I want this to run perfectly.
Try:
::basic::#include <iostream> int main(){{}{}}
Related
The man page for mmap on my machine says:
#include <sys/mman.h>
void *mmap(void *addr, size_t len, int prot, int flags,
int fildes, off_t off);
Some man page viewers, such as Emacs, convert the include statement into a hyperlink, allowing me to view /usr/include/sys/mman.h, which really helpful.
Is there any way I can jump to the source code itself of the function being documented (from the man page)?
NO_XSLOCKS allows the usage of some error checking macros in XS code when combined with #include XSUB.h. However, its use seems to go beyond that. It was recently suggested that I add it to my XS file for better compatibility with ActiveState perl, with this issue given as an example.
What else does #define NO_XSLOCKS do, and when should I use it in my XS code?
I am working with C++ in org babel and would like to know how to format the includes so that I can list more than one.
Here's what I'm trying (that fails)
#+BEGIN_SRC C++ :includes <cstdio> :includes <iostream> :includes <string>
using namespace std;
printf("Hello ");
cout << "world\n";
#+END_SRC
In this case both printf and cout are undeclared in this scope. I can drop the unnecessary :includes <string> from the headers and the cout doesn't kick up an error, so it seems like only the last :includes counts. I have tried loading multiple includes into the same line using nothing, commas and spaces as delimiters and I always get an error about extra tokens at the end of the include directive. I have also tried using :includes+ in case that worked on the header line, but it didn't.
I'm fairly certain that what I'm trying to do should be possible because it says in the documentation that
:includes
(C & CC+ only) accepts either a single string name, or a list of names of files to #include in the execution of the code block
Org-version: 8.2.7-4-g880362-elpa
EDIT:
It's worth noting that other header arguments can just be strung together (i.e. :results raw drawer will produce unformatted results in a drawer), so there's a decent chance that this is a bug. Using :include <cstdio> <iostream> produces a compiler error that there's an extra token at the end of the #include <cstdio> line.
EDIT 2:
Turns out it's actually a bug in org, so it's been submitted.
After some experimenting, during which I noticed that some error messages look fairly lispy, and using the superficial knowledge I have of Lisp, I found the answer:
#+begin_src C++ :includes '("<math.h>" "<iostream>" "<algorithm>")
// Freely use symbols from those headers
#+end_src
Another issue that I'm having is that I can only get it to execute if I capitalize C++ but I only get syntax highlighting if I use minuscules ("c++"). Pure joy.
I configured my cedet almost the same with http://alexott.net/en/writings/emacs-devenv/EmacsCedet.html.
Thanks alexott , most of the time it works well, but I found that it can not well parse the tm struct in /usr/include/time.h.
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void){
struct tm times;
FILE file;
}
When using M-x semantic-ia-fast-jump, the struct FILE is correct, but semantic finds the struct tm in wchar.h, not in time.h.
The problem seems to be there is a forward declaration in wchar.h for the struct tm.
In my copy of time.h, it appears that the symbol __BEGIN_NAMESPACE_STD is showing up in front of the struct declaration, and is befuddling the parser. You can fix that quickly by just adding that and __END_NAMESPACE_STD to the variable semantic-lex-c-preprocessor-symbol-map as mapping to empty. Then delete your semanticdb cache files (in ~/.semanticdb) related to time.h, or just everything in /usr/include, and restart emacs. time.h should get reparsed, and things should work ok for time.h after that... unless you want to use std::tm or something.
I'm trying to use sed to delete all occurrences of
#ifdef _WIN32
#endif
Where all that exists between #ifdef and #endif is an empty line. I have limited experience using sed, I've read some documentation on the multi line features but I can't seem to figure it out. Any help is appreciated!
You can try sed -e '/^#ifdef _WIN32/,/^#endif/d' but it does not generalize to more complex cases of nesting.
For this job, I'd recommend using a tool designed for the job - rather than sed.
Use coan; it has a mode for editing #ifdef and #ifndef and #if and #elsif lines selectively. For example, you'd use:
coan source -U_WIN32 sourcefile.c
This would deal with all _WIN32 sections, leaving behind only what was necessary.
See also my related question: Is there a C pre-processor which eliminates #ifdef blocks based on values defined/undefined?
If there exists pairs of #ifdef _WIN32/#endif that have non-empty lines between them that you don't want to delete, then use the following:
sed 'N;N;s/\n#ifdef _WIN32\n[[:space:]]*\n#endif\n/\n/;P;D'
Input
this is the first line
#ifdef _WIN32
// Don't delete this comment!
#endif
stuff here
more stuff here
#ifdef _WIN32
#endif
last line
Output
$ sed 'N;N;s/\n#ifdef _WIN32\n[[:space:]]*\n#endif\n/\n/;P;D' ifdef.sed
this is the first line
#ifdef _WIN32
// Don't delete this comment!
#endif
stuff here
more stuff here
last line