Programming :: C++: Macro Not Defined In Quotes?
Dec 12, 2009
I converted my programming project over to autotools, which gives me a config.h file with all the cool definitions, like these ones:
Code:
/* Location of data files. */
#define DATADIR "/usr/local/share"
/* Define to the full name of this package. */
#define PACKAGE_NAME "lusus"
And naturally I think this is cool because then I can hardcore these into the binary. To my dismay, however, I discovered that the pre-processor does not do the text-substitution if the macro name is inside another quoted string.
Code:
// Prints out "/usr/local/share/lusus"
std::cout << DATADIR << "/" << PACKAGE_NAME << "
";
[code]....
This seems lame, because then this doesn't work:
Code:
CL_Image leaves_corner_tl(gc, "DATADIR/PACKAGE_NAME/img/leaves_corner_tl.png");
So, am I literally going to have to strcat DATADIR/PACKAGE with the other text every time I want to prefix DATADIR/PACKAGE_NAME onto another string?
View 2 Replies
ADVERTISEMENT
Mar 20, 2011
I've been reviewing some source code recently which contains many conditional compilation statements, and I found it hard to understand the code not knowing whether some macro is defined or not. Is there any way to test whether a macro is defined?
View 2 Replies
View Related
Jun 27, 2009
I am dealing with some Linux kernel code, which define most its functions with Macros.The trouble I am having is to use those code in user space in Windows.
For example, I have a function defined like this:
#define list_for_each_entry_safe(pos, n, head, member)
for (pos = list_entry((head)->next, typeid(*pos), member),
n = list_entry(pos->member.next, typeid(*pos), member);
&pos->member != (head);
pos = n, n = list_entry(n->member.next, typeid(*n), member))
And in user space code, I call it in this way:
list_for_each_entry_safe( pcre_item, tmp,
&(((pcre_list_head_t *)(hr.value))->head), list)
{
// My code to handle each element in the list
}
This is working like a charm in Linux, but I got errors in Windows:
It reminds me missing ';' after 'list_for_each_entry_safe( pcre_item, tmp,
&(((pcre_list_head_t *)(hr.value))->head), list)'.
Does this kind of linux code not working in Windows at all? (Linux is in GCC C stand and VC is ANSI C) I prefer not to convert them to normal functions but keep it the way if it could be working under windows by some tricks.
View 5 Replies
View Related
Jun 6, 2010
In bash I need to use some equivalent of double quotes inside double quotes (or the other way around.)I need to run the following statement to get the output of foo and store it in a variable while passing foo the $file which probably contains spaces.
Code:
variable=$(foo "$file")
The problem is that foo might return an empty string and if it does I need to catch it
[code]...
View 6 Replies
View Related
Aug 2, 2011
I am not sure If anybody has faced this issue, my keyboard is less responsive when pressing the double quote/single quote key, I have to press it twice for it to print the quote( and that too it prints some other data and not exactly a double-quotes). Initially I thought it was issue with my keyboard, but later I see that it is working fine in Windows XP. It looks some kind of setting issue. If you check the below two examples, example a) is the double quote printed in Ubuntu, it doesnt exactly looks like a double-quotes and b) is the one printed in Windows.
View 1 Replies
View Related
Apr 13, 2010
I have my own declared types and I have to operate with lists of items. I wish to write a one macro, instead of using a function for each type. It's intended to be like this: Code: #define ____append_to_list(head,
item, type)
type* ptr;
for ( ptr = head; ptr->next != NULL; ptr = ptr->next )
[code].....
View 9 Replies
View Related
Aug 18, 2010
All I'm trying to do is ShellExecute a program every time a new slide appears.
I'm using Office 2003 Powerpoint.
I did the following:
1. Tools, Options, Security Options, Macro Security, Security Level= Medium
2. Tools, Options, Macro, VBA Editor:
Code:
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
MsgBox ("OnSlideShowPageChange")
End Sub
3. File, Save
4. Back to PowerPoint: F5) Slide Show, View Show <= Did NOT see the message box
5. Exit out of Powerpoint, reopen the .ppt file, F5) again <= Still don't see the message box
why isn't "OnSlideShowPageChange" getting invoked when I run the slide show?
View 3 Replies
View Related
Dec 3, 2010
integrate a macro from MS Word to Open Office? It is a script I need for music. I cannot upload the file here nor give you the link, because I'm not let.
View 9 Replies
View Related
Jan 29, 2011
telling the exact macro name and location, by which I can gain control over the following kernel base level structure
1. strct super_block of Virtual File System, for super block object.
2. strct inode for inode ofject of VFS.
3 file structure for file object of VFS.
in addition to these if you know location to access other kernel structure.Please let me know.My main objective is to get the access to the structure pointer of these structure by which i can have access over the individual fields o these structure.
View 11 Replies
View Related
Nov 21, 2010
I am trying to understand working of pci_resource_start function So I browsed code via cscope and searched for string pci_resource_start and got following in pci.h
Code:
#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
I am not able to understand how does this above macro works. How does it above macro gets appropriate base address register in configuration space?
View 1 Replies
View Related
Nov 4, 2010
I'm trying to write a bash script that has to extract values from a csv file. Problem is there are lines like this:a,b,c,"dd,dd,dd",e,f,gI'm using awk to extract the values but when I try it extract value 4 with awk I get:"ddinstead of:"dd,dd,dd"Does anyone know how to get awk to ignore commas within double quotes?
View 5 Replies
View Related
Feb 18, 2010
The following script will work when I type the path to the file I want to checksum, but not when I drag the file to the terminal because the linux terminal (unlike the Mac) automatically puts quotes around the file path, which causes an error. (Clarification: am referring to gnome-terminal. Thanks, GrapefruiTgirl.) I did not find anything in gconf-editor or anywhere else to alter this behaviour, and my post in Launchpad is unanswered so far. (the script in itself is not very useful, I just stumbled upon this error when experimenting with bash).
So, is there a workaround for stripping the quotes from the input, or can I configure the terminal to not quote the input when I drag a file into it (which I would prefer?)
I am currently logged in from Mac OS, but the question refers to ubuntu karmic with which I dual boot.
View 6 Replies
View Related
Jul 20, 2011
grep -e XkbLayout /etc/X11/xorg.conf | grep -v "^#" | awk '{print $3}'
output = "gb"
sometimes= "us"
View 4 Replies
View Related
Mar 18, 2011
After I assign a string to a variable, I know that the print function will remove the single quotes around the value, but is there a way to assign a variable without the quotes around the value? for example:
a = open('/usr/lib', 'r+')
b = f.read()
c = x.replace('.xx','yy')
d = ?
c returns the value with quotes around it print c returns the value without the quotes Is there a way to assign a new variable (d) which will equal c without the quotes? I need a new variable which has the quotes omitted because from there the script will take the value of the last variable (which is a path to a file), and tar up that file. It won't recognize the path to the file if the value has quotes around it.
View 1 Replies
View Related
May 2, 2010
I wrote the Automatik widget (you can find it at :http://kde-look.org/content/show.php...&PHPSESSID=caeTo improve it, I would like to add this one-line script into a text sensor :
top -b -n 1 | head -12 | tail -6 | sed '/top/d' | awk '{ printf "%-12.12s %-4s %-4s %-3s
" , $12,$9,$10,$2}'
[code]...
View 3 Replies
View Related
Sep 13, 2010
i'm practicing in very basic c programs using the gcc compiler.I found that when i create two variables let's say
Code:
int a,b and Code: a=15;
b=3;
a=b;
b--;
then a equals 2.I thought that this isn't normal in C isn't it?I haven't had the time to read the gcc documentation yet...so i think it has something to do with my compiler's default settings.I use the
Code: gcc filename.c -o filename command to compile
Are all variables defined like pointers?
View 5 Replies
View Related
Apr 17, 2011
I have a Red Hat 4.9 server running python 2.3.4. However I need some of the new functions so I downloaded and installed Python 2.7.1. I wanted to use the "set" function which was not in the earlier version.
/bin/python is 2.3.4
/usr/local/bin/python is 2.7.1
I have a script running 2.3.4 which calls the 2.7.1 script however it fails because it cannot find the "set" command here is an example
Script1
#!/bin/python
import Mytest
[code]....
The error message is :
NameError: global name 'set' is not defined
View 14 Replies
View Related
Jun 17, 2011
I found an interesting screencast online about how to make gtk Pyton apps. The thing is, though, the guy was using the interactive shell. I've been trying to get his code into a script, and have been having troubles.
Here's what I got:
Code:
It spits out the error "NameError: global name 'browser' is not defined"
I know I'm doing something wrong with how I'm telling it where to find "browser" and "text", but I can't figure out how to point it to the right place.
View 5 Replies
View Related
Sep 17, 2010
I recently was pointed to [URL] in another thread and ran into a problem: What header file do I need to download to write the code in the documentation? Apparently no 'bignum.h' file on the Internet declares the "BN_ULONG" macro or "BN_BITS2" bit chunks.
View 1 Replies
View Related
Feb 8, 2011
I am writing an expect script and I wish to use environment variables that are defined outside of the script.
View 6 Replies
View Related
Jan 24, 2011
I wrote a shell script and was able to compile it using SHC. after that i copied it to the /bin folder and tried running it as a normal user, but i keep getting the error " operation not permitted killed "
I tried changing the permissions. but it doesn't work. it only works with sudo. there must be another way. otherwise it won't be linux right?
View 11 Replies
View Related
Feb 19, 2010
I have created a file with a pre-defined size as follows:
Code:
#define FILEPATH "testfile"
#define FILESIZE 16
[code]...
View 5 Replies
View Related
Oct 12, 2010
The first line of this struct:
Code:
struct custom_int {
typedef int big_int;
[code]...
View 4 Replies
View Related
Apr 29, 2011
i got a sample.c which generate a linked list for sorting according to the number generated. then i want to split the sorting function into a header file. and it looks like the sort function in the header file could not access the linked list in the main. the error is dereferencing pointer to incomplete type
sample.c
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
[code]...
View 2 Replies
View Related
Jul 7, 2010
Here is the block of code : (The red part is the code that doesn't work) The file is not created and see the output after the code. # i loop create environment structure and k loop create std procedure sub structure.
for i in TRAX2 TRAX BENCH PROD
do
eval mkdir $"acsayul02501_${i}"
eval chmod 2770 $"acsayul02501_${i}"
[code]....
View 3 Replies
View Related
Dec 29, 2010
i have Ubuntu10.10 (kernel-2.6.35-22-generic) installed. struct stat StatBuff;
[Code]...
I have mounted a windows share folder on /mnt. When i gave any directory within /mnt/ to stat function it fails with errorno 75. perror shows "Value too large for defined data type". Example 1 is fail but Example 2 works fine.
View 7 Replies
View Related
Jun 15, 2011
I recently noticed that my libreoffice doesn't have the "Record Macro" voice that used to be in OpenOffice Tools -> Macros. Is that normal or have I installed libreoffice incorrectly?
View 6 Replies
View Related
Nov 10, 2010
I am looking to make a macro that will log me in on a website whenever I connect to the internet. Specifically, this macro has to input a username and password, and then press the login button. Is there any way to do this?
View 1 Replies
View Related
Feb 23, 2010
I'm currently using a version of scientific linux with X windows. Is there a program I can use to set the mouse and keyboard to go through a series of commands and loop? there's a program I'm using for my research and to go into the inner workings of it to set up a script to run it will be very difficult.Instead, just having the keyboard and mouse loop through some commands would be much easier.
View 1 Replies
View Related
Mar 3, 2010
I'm using openSUSE 11.2 x86_64 and I've installed OpenOffice.org 3.2.0 from Index of /repositories/OpenOffice.org:/STABLE/openSUSE_11.2 . However, the menu option Tools->Macros->Record Macro is missing (it is present in the official build of OpenOffice.org for windows and the one distributed in archlinux). Is this a bug? I've searched the Novell bugzilla for resolved and open bugs for this, but I've found nothing.
View 1 Replies
View Related