Programming :: How To Test Whether A Macro Is Defined

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


ADVERTISEMENT

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 View Related

Programming :: Convert Macro Defined Functions From Kernel In Visual C++?

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

Programming :: Append Item To A List ( C Macro )?

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

Programming :: Can't Get VBA Macro To Run In Powerpoint Slide Show

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

Programming :: Integrate A MACRO Command In Open Office?

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

Programming :: Macro To Access Kernel Objectys Structure?

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

Programming :: Macro To Get Base Address Register In Configuration Space?

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

Programming :: C With Gcc: Are All Variables Defined Like Pointers

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

Programming :: NameError: Global Name 'set' Is Not Defined

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

Programming :: Python - Global Name Not Defined

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

Programming :: Bignum Library And 'BN_ULONG' Macro: Not Declared In Bignum.h!

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

Programming :: Use Environment Variables That Are Defined Outside Of The Script?

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

Programming :: Run A User-defined Command Without Sudo ?

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

Programming :: Created A File With A Pre-defined Size ?

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

Programming :: Error: New Types May Not Be Defined In A Return Type?

Oct 12, 2010

The first line of this struct:

Code:
struct custom_int {
typedef int big_int;

[code]...

View 4 Replies View Related

Programming :: Including User Defined Header File?

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

Programming :: Test If File Is In Use?

May 4, 2010

I want to copy files from an incoming directory, but don't want to copy a file if it hasn't finished being written. I thought of using fuser, but it doesn't seem to be very reliable. I vi'd a file in one window and then ran fuser against the file name and got nothing back. I'm just writing a simple bourne script on RHEL.

View 5 Replies View Related

Programming :: Test Program To Get The CPU Utilisation

Mar 9, 2010

I wrote a test program to get the CPU utilisation. I hope to extend it to take cpu utilisation on multi core machines. Hear I used the equation for taking cpu utilisation given at [url] of JmSchanck post. But when I match the output of my program against 'top' and 'system monitor' output it seems quite high. Sometimes cpu utilisation goes more than 100%.

So the given equation in that url is correct? can anyone give me the equation to take CPU utilisation?

Code:

View 3 Replies View Related

Programming :: How To Get Grep Output 0 - 1 And Test It

Apr 7, 2009

I am trying to use a shell script to find a string in a file and do something when found. code...

What should happen is pppd will start in a different process and stream it's output to pppdout. pppdout should be created in the current folder. Then the script should periodically check the pppdout file for the string Script (which eventually will appear, some seconds later) and when found exit the script. Ultimately the script will do something useful when the text is found. However, the output from the program is a repeating: 'scriptname.sh: 12: FOUND: not found'

Where scriptname.sh would be the name of your script and 12 refers to the line with 'done'.

Why does grep not find the text, or at least why deos my script not check the grep output correctly?

View 10 Replies View Related

Programming :: How To Test Kate Plugins

Mar 20, 2011

I wanted to make some modifications to a Kate plugin, so I cloned the git repository, started doing a few changes, and it compiled. The problem is that when I run it, it uses the version of the plugin installed in the system, not the one compiled with Kate.

View 1 Replies View Related

Programming :: Send The Output Of A Command In A File Defined By A Eval $"$var1"?

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

Programming :: Passing Input To Program For Test

Apr 13, 2011

I started to run a C++ my program in Linux and I don't know how to test my program that works fine with a text file. This is a project for my uni and to explain more clear, My program is a sample database for modify or add and search and it read data from a binary file and also write into a binary file. I have got an input from my lecture and she said after compiling in Linux I must write:

1-to compile:
Code:
g++ (files with cpp)
2-to see the output:
Code:
./a.out
3-to test with input:
Code:
./a.out < input.txt >

My problem is in step three. What I must write in the command part after" step2" to see the output?

View 3 Replies View Related

Programming :: How To Test Disown And Nohup Commands

Mar 20, 2010

I ran a perl script in background with nohup and disown to make sure my script runs even after the parent process is terminated.

Method 1: nohup
> nohup perl run.pl &
[1] 2080

Method 2: disown
> perl run.pl &
[2] 2448
> disown

In either method, the script process doesn't seem to connect to init process, when I checked using pstree command. I thought, the disown or nohup command detaches the process from its parent and attaches it to grand grand parent init process. And it disables SIGHUP signal to my script process. But the pstree command didn't show me what I expected. It still shows my script process attached to my current terminal process. I just don't understand the concept behind these two commands (nohup and disown). Is there any way, I can see the list of processes that are run by nohup or disown command?

View 2 Replies View Related

Programming :: Insert A Line In The Test File With Sed?

Jul 15, 2010

I have following file workers file: There are 800 entries like this.

# consensus/uat
worker.consensus-uat1.host=lonlx10409
worker.consensus-uat1.port=13702
worker.consensus-uat1.type=ajp13

[code]....

I want to insert one line just below the line starting with "woker.list". I think sed can do it but I am not aware.

View 14 Replies View Related

Programming :: Perl - Test If String Is Uppercase

Jan 6, 2010

In my perl script I'd like to test if a string is written in uppercase letters or not. How can I do that? This type of test don't seem to work, so there must be other ways of doing this:

Code:

...return true.

I can create a subroutine that compares each character aginst a list of uppercase letters, but I'm hoping there's allready a build in routine in perl that does this...

View 14 Replies View Related

Programming :: PHP - Ping Test In Shell / CMD Window

Mar 4, 2010

I'm trying to do the following. from a php webpage click on a link, that opens a shell/cmd and runs an open ping to the device. so it must actually open a shell (for linux) or cmd (for windows) and run a ping to the specified ip. Currently i'm running an exec command, but for this i need to wait for the result to be fetched and print it out. I want to monitor it in realtime, by just clickingon the button. How to get this working?

View 1 Replies View Related

Programming :: Test App That Scans For Plugins In A Directory?

Aug 27, 2010

I wrote a test app that scans for plugins in a directory, calls their getWidget() method (implemented in my interface), and adds that widget to a layout.

The problem is that when I added a QTimer to my plugin class, it didn't work! Why?

And will it be easier to write the thing in Python and not use QPlugin? I just want to define a QWidget and have it added to the app.

View 8 Replies View Related

Programming :: Script To Test If Program Is Running

Sep 22, 2010

I'm trying to test whether wget is working still or not. While [ wget is still running ] <----- but how should this look please?
do
codes
done

View 4 Replies View Related

Programming :: Python - Attempting To Test The Bin Function?

Jul 31, 2010

I am exploring the Python 3 standard library and am currently attempting to test the bin function. It converts an integer into a binary string. I believe the module I wrote is flawed somehow. Here's the source code:

Code:

#!/usr/bin/python3.1

#This module tests the bin() function.

import sys
def get_input():
x = input("Enter an integer: ")
def use_bin():

[code]....

As you can see, the binary form given is always 0b10111. I'm no expert on binary code (or hexadecimal notation), but surely 9000 and two would have different results?

EDIT: Added a line in the module to repeat back what integer the user entered, and then the binary form. It would appear that no matter what integer the user enters, Python thinks it's "23".

Example output:

Code:

>>>
Enter an integer: 1
You entered 23
The binary form of this integer is 0b10111
>>>

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved