473,413 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Elementary question on preprocessors and xlw

I am using the xlw package as a c++ wrapper for excel functions. In
our c++ library, there is an excel function which our c++ developers
refer to as DevelopersFunction, and which the excel users refer to as
ExcelFunction. [Names of functions changed to preserve corporate
confidentiality]

There is some code containing the string "DevelopersFunction" which
results in the excel users seeing the text DevelopersFunction when
they use the insert_function command in excel.

But the excel users should see "ExcelFunction"

I would imagine that this can be done by a simple preprocessor #define
command.
I tried to rename the function to ExcelFunction in excel and then
#define DevelopersFunction ExcelFunction

But this doesn't appear to work.

Any suggestions.

Thanks,

Paul Epstein

Oct 4 '07 #1
11 1518
On Oct 4, 7:45 pm, pauldepst...@att.net wrote:
I am using the xlw package as a c++ wrapper for excel functions. In
our c++ library, there is an excel function which our c++ developers
refer to as DevelopersFunction, and which the excel users refer to as
ExcelFunction. [Names of functions changed to preserve corporate
confidentiality]

There is some code containing the string "DevelopersFunction" which
results in the excel users seeing the text DevelopersFunction when
they use the insert_function command in excel.

But the excel users should see "ExcelFunction"

I would imagine that this can be done by a simple preprocessor #define
command.
I tried to rename the function to ExcelFunction in excel and then
#define DevelopersFunction ExcelFunction

But this doesn't appear to work.

Any suggestions.
To be honest, I can't follow your description of
the problem, and I don't know of any "packages"
(at least not in a the C++ context).

Maybe you can look at using a 'typedef'?

Please try to be a little more clear and someone
else might be able to help you.

--
Chris Val



Oct 4 '07 #2
On Oct 4, 7:05 pm, "Chris ( Val )" <chris...@gmail.comwrote:
On Oct 4, 7:45 pm, pauldepst...@att.net wrote:


I am using the xlw package as a c++ wrapper for excel functions. In
our c++ library, there is an excel function which our c++ developers
refer to as DevelopersFunction, and which the excel users refer to as
ExcelFunction. [Names of functions changed to preserve corporate
confidentiality]
There is some code containing the string "DevelopersFunction" which
results in the excel users seeing the text DevelopersFunction when
they use the insert_function command in excel.
But the excel users should see "ExcelFunction"
I would imagine that this can be done by a simple preprocessor #define
command.
I tried to rename the function to ExcelFunction in excel and then
#define DevelopersFunction ExcelFunction
But this doesn't appear to work.
Any suggestions.

To be honest, I can't follow your description of
the problem, and I don't know of any "packages"
(at least not in a the C++ context).

Maybe you can look at using a 'typedef'?

Please try to be a little more clear and someone
else might be able to help you.

--
Chris Val- Hide quoted text -

- Show quoted text -
Thanks.

I have found a way of clarifying the problem, now that I understand
the issue better myself

I have a constructor called MyConstructor which takes a const
std::string & parameter.

I want the preprocessor to translate MyConstructor("dog") into
MyConstructor("cat").

This seems like a #define problem rather than a typedef problem.

Thanks again,

Paul Epstein

Oct 4 '07 #3
On Oct 4, 9:23 pm, pauldepst...@att.net wrote:
On Oct 4, 7:05 pm, "Chris ( Val )" <chris...@gmail.comwrote:


On Oct 4, 7:45 pm, pauldepst...@att.net wrote:
I am using the xlw package as a c++ wrapper for excel functions. In
our c++ library, there is an excel function which our c++ developers
refer to as DevelopersFunction, and which the excel users refer to as
ExcelFunction. [Names of functions changed to preserve corporate
confidentiality]
There is some code containing the string "DevelopersFunction" which
results in the excel users seeing the text DevelopersFunction when
they use the insert_function command in excel.
But the excel users should see "ExcelFunction"
I would imagine that this can be done by a simple preprocessor #define
command.
I tried to rename the function to ExcelFunction in excel and then
#define DevelopersFunction ExcelFunction
But this doesn't appear to work.
Any suggestions.
To be honest, I can't follow your description of
the problem, and I don't know of any "packages"
(at least not in a the C++ context).
Maybe you can look at using a 'typedef'?
Please try to be a little more clear and someone
else might be able to help you.
--
Chris Val- Hide quoted text -
- Show quoted text -

Thanks.

I have found a way of clarifying the problem, now that I understand
the issue better myself
Good :-)
I have a constructor called MyConstructor which takes a const
std::string & parameter.

I want the preprocessor to translate MyConstructor("dog") into
MyConstructor("cat").

This seems like a #define problem rather than a typedef problem.

Thanks again,
# include <iostream>
# include <string>

struct Foo
{
Foo( const std::string& s );
};

// Try with and without this (comment out)...
#define DevelopersFunction "DevelopersFunction"

# if defined DevelopersFunction
Foo::Foo( const std::string& s ) {
std::cout << s << " from: DevelopersFunction\n";
}
#else
Foo::Foo( const std::string& s ) {
std::cout << s << " from: ExcelFunction\n";
}
#endif
int main()
{
Foo( "arg" );

std::cin.get();
return 0;
}

Does his help?

--
Chris val

Oct 4 '07 #4
On 2007-10-04 13:23, pa**********@att.net wrote:
On Oct 4, 7:05 pm, "Chris ( Val )" <chris...@gmail.comwrote:
>On Oct 4, 7:45 pm, pauldepst...@att.net wrote:


I am using the xlw package as a c++ wrapper for excel functions. In
our c++ library, there is an excel function which our c++ developers
refer to as DevelopersFunction, and which the excel users refer to as
ExcelFunction. [Names of functions changed to preserve corporate
confidentiality]
There is some code containing the string "DevelopersFunction" which
results in the excel users seeing the text DevelopersFunction when
they use the insert_function command in excel.
But the excel users should see "ExcelFunction"
I would imagine that this can be done by a simple preprocessor #define
command.
I tried to rename the function to ExcelFunction in excel and then
#define DevelopersFunction ExcelFunction
But this doesn't appear to work.
Any suggestions.

To be honest, I can't follow your description of
the problem, and I don't know of any "packages"
(at least not in a the C++ context).

Maybe you can look at using a 'typedef'?

Please try to be a little more clear and someone
else might be able to help you.

--
Chris Val- Hide quoted text -

- Show quoted text -

Thanks.

I have found a way of clarifying the problem, now that I understand
the issue better myself

I have a constructor called MyConstructor which takes a const
std::string & parameter.

I want the preprocessor to translate MyConstructor("dog") into
MyConstructor("cat").

This seems like a #define problem rather than a typedef problem.
#include <iostream>
#include <string>

#ifdef NDEBUG
#define WORD "dog"
#else
#define WORD "cat"
#endif

struct Foo
{
std::string str;
Foo(const std::string& s) : str(s) { }
};
int main()
{
Foo f(WORD);
std::cout << f.str;
}

You just have do figure out something to test against instead of NDEBUG
and it should all work.

--
Erik Wikström
Oct 4 '07 #5
On Oct 4, 7:41 pm, "Chris ( Val )" <chris...@gmail.comwrote:
On Oct 4, 9:23 pm, pauldepst...@att.net wrote:


On Oct 4, 7:05 pm, "Chris ( Val )" <chris...@gmail.comwrote:
On Oct 4, 7:45 pm, pauldepst...@att.net wrote:
I am using the xlw package as a c++ wrapper for excel functions. In
our c++ library, there is an excel function which our c++ developers
refer to as DevelopersFunction, and which the excel users refer to as
ExcelFunction. [Names of functions changed to preserve corporate
confidentiality]
There is some code containing the string "DevelopersFunction" which
results in the excel users seeing the text DevelopersFunction when
they use the insert_function command in excel.
But the excel users should see "ExcelFunction"
I would imagine that this can be done by a simple preprocessor #define
command.
I tried to rename the function to ExcelFunction in excel and then
#define DevelopersFunction ExcelFunction
But this doesn't appear to work.
Any suggestions.
To be honest, I can't follow your description of
the problem, and I don't know of any "packages"
(at least not in a the C++ context).
Maybe you can look at using a 'typedef'?
Please try to be a little more clear and someone
else might be able to help you.
--
Chris Val- Hide quoted text -
- Show quoted text -
Thanks.
I have found a way of clarifying the problem, now that I understand
the issue better myself

Good :-)
I have a constructor called MyConstructor which takes a const
std::string & parameter.
I want the preprocessor to translate MyConstructor("dog") into
MyConstructor("cat").
This seems like a #define problem rather than a typedef problem.
Thanks again,

# include <iostream>
# include <string>

struct Foo
{
Foo( const std::string& s );
};

// Try with and without this (comment out)...
#define DevelopersFunction "DevelopersFunction"

# if defined DevelopersFunction
Foo::Foo( const std::string& s ) {
std::cout << s << " from: DevelopersFunction\n";
}
#else
Foo::Foo( const std::string& s ) {
std::cout << s << " from: ExcelFunction\n";
}
#endif

int main()
{
Foo( "arg" );

std::cin.get();
return 0;
}

Does his help?

--
Chris val- Hide quoted text -

- Show quoted text -
Chris,

I appreciate your attempt to help me but this seems like a poor
solution because it involves constantly changing the c++ code
depending on whether an EXCEL user or a developer is using it.

The idea is for the same piece of code to work to provide a different
function name depending on whether the source code is being looked at,
or whether the xll is being run.

Paul

Oct 4 '07 #6
On Oct 4, 7:54 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
On 2007-10-04 13:23, pauldepst...@att.net wrote:


On Oct 4, 7:05 pm, "Chris ( Val )" <chris...@gmail.comwrote:
On Oct 4, 7:45 pm, pauldepst...@att.net wrote:
I am using the xlw package as a c++ wrapper for excel functions. In
our c++ library, there is an excel function which our c++ developers
refer to as DevelopersFunction, and which the excel users refer to as
ExcelFunction. [Names of functions changed to preserve corporate
confidentiality]
There is some code containing the string "DevelopersFunction" which
results in the excel users seeing the text DevelopersFunction when
they use the insert_function command in excel.
But the excel users should see "ExcelFunction"
I would imagine that this can be done by a simple preprocessor #define
command.
I tried to rename the function to ExcelFunction in excel and then
#define DevelopersFunction ExcelFunction
But this doesn't appear to work.
Any suggestions.
To be honest, I can't follow your description of
the problem, and I don't know of any "packages"
(at least not in a the C++ context).
Maybe you can look at using a 'typedef'?
Please try to be a little more clear and someone
else might be able to help you.
--
Chris Val- Hide quoted text -
- Show quoted text -
Thanks.
I have found a way of clarifying the problem, now that I understand
the issue better myself
I have a constructor called MyConstructor which takes a const
std::string & parameter.
I want the preprocessor to translate MyConstructor("dog") into
MyConstructor("cat").
This seems like a #define problem rather than a typedef problem.

#include <iostream>
#include <string>

#ifdef NDEBUG
#define WORD "dog"
#else
#define WORD "cat"
#endif

struct Foo
{
std::string str;
Foo(const std::string& s) : str(s) { }

};

int main()
{
Foo f(WORD);
std::cout << f.str;

}

You just have do figure out something to test against instead of NDEBUG
and it should all work.

--
Erik Wikström- Hide quoted text -

- Show quoted text -
Thanks a lot, Erik

I believe I can implement this idea!

Paul Epstein

Oct 4 '07 #7
On Oct 5, 12:19 am, pauldepst...@att.net wrote:
On Oct 4, 7:41 pm, "Chris ( Val )" <chris...@gmail.comwrote:
[snip]
I appreciate your attempt to help me but this seems like a poor
solution because it involves constantly changing the c++ code
depending on whether an EXCEL user or a developer is using it.

The idea is for the same piece of code to work to provide a different
function name depending on whether the source code is being looked at,
or whether the xll is being run.
It's not a difficult problem to solve at all, and in fact
it was very simple what Erik provided you with.

The problem for me as I outlined from the beginning, is
that I really didn't understand your requirements, so
just tried to provide an idea.

Anyway, glad you got what you were looking for :-)

--
Chris Val


Oct 4 '07 #8
On Oct 4, 10:50 pm, "Chris ( Val )" <chris...@gmail.comwrote:
On Oct 5, 12:19 am, pauldepst...@att.net wrote:
On Oct 4, 7:41 pm, "Chris ( Val )" <chris...@gmail.comwrote:

[snip]
I appreciate your attempt to help me but this seems like a poor
solution because it involves constantly changing the c++ code
depending on whether an EXCEL user or a developer is using it.
The idea is for the same piece of code to work to provide a different
function name depending on whether the source code is being looked at,
or whether the xll is being run.

It's not a difficult problem to solve at all, and in fact
it was very simple what Erik provided you with.

The problem for me as I outlined from the beginning, is
that I really didn't understand your requirements, so
just tried to provide an idea.

Anyway, glad you got what you were looking for :-)

--
Chris Val
Chris,

Everything you say is correct.

1) The problem was simple -- I never claimed to be an expert.

2) I didn't explain the problem clearly at the beginning.

3) Erik provided a simple solution.

However, I did make an additional point which is of some value, and I
stand by it:

4) This snippet of code of yours is _bad practice_ no matter what
problem you thought I had.

Beginning of quote

// Try with and without this (comment out)...
#define DevelopersFunction "DevelopersFunction"

End of quote.

It is simply bad style to use commenting out in this way.
So it does seem appropriate, in a coding forum for me to point out
that this is bad, and explain why, particularly since I thanked you
for your help at the beginning.

Paul Epstein


Oct 5 '07 #9
On Oct 5, 10:30 am, pauldepst...@att.net wrote:
On Oct 4, 10:50 pm, "Chris ( Val )" <chris...@gmail.comwrote:


On Oct 5, 12:19 am, pauldepst...@att.net wrote:
On Oct 4, 7:41 pm, "Chris ( Val )" <chris...@gmail.comwrote:
[snip]
I appreciate your attempt to help me but this seems like a poor
solution because it involves constantly changing the c++ code
depending on whether an EXCEL user or a developer is using it.
The idea is for the same piece of code to work to provide a different
function name depending on whether the source code is being looked at,
or whether the xll is being run.
It's not a difficult problem to solve at all, and in fact
it was very simple what Erik provided you with.
The problem for me as I outlined from the beginning, is
that I really didn't understand your requirements, so
just tried to provide an idea.
Anyway, glad you got what you were looking for :-)
--
Chris Val

Chris,

Paul,
Everything you say is correct.

1) The problem was simple -- I never claimed to be an expert.
Correct, and I never claimed otherwise.
2) I didn't explain the problem clearly at the beginning.
Correct.
3) Erik provided a simple solution.
Correct.
However, I did make an additional point which is of some value, and I
stand by it:
Yes, *some* value, which allowed me to present you
with *an idea*.
4) This snippet of code of yours is _bad practice_ no matter what
problem you thought I had.
You can call it what you like. It was an idea, that's
all and nothing more to it. I didn't expect you to
implement exactly what I provided, that is your job
because you are the domain expert and in complete
understanding of your problem.

I explained that I still did not fully understand your
requirements, and my sole intention was to put forward
*an idea* for you to work with.
Beginning of quote

// Try with and without this (comment out)...
#define DevelopersFunction "DevelopersFunction"

End of quote.

It is simply bad style to use commenting out in this way.
When trying to show someone how to use *an idea* they
have put forward, and to see the side effects of using
it, the most experienced of us do it all the time.
So it does seem appropriate, in a coding forum for me to point out
that this is bad, and explain why, particularly since I thanked you
for your help at the beginning.
I think you have missunderstood the whole point of my
example and reply.

I appreciate you thanking me for the help, and that's
all I tried to do. However, you have to understand that
people give their time in helping others here for
free, and often present *ideas*, and not necessarily
*complete solutions* - After all, this is not a help
desk.

I did not abuse you, try to belittle you, nor make
any claims that the example code I provided was the
right solution for you.

Please take these facts into consideration when
responding to people who are trying to help you
in the future.

--
Chris Val
Oct 5 '07 #10
"Chris ( Val )" <chris...@gmail.comwrote:
>
I did not abuse you, try to belittle you, nor make
any claims that the example code I provided was the
right solution for you.

Please take these facts into consideration when
responding to people who are trying to help you
in the future.

--
Chris Val- Hide quoted text -
No, you did not abuse me, but I certainly _did_ think that you were
trying to belittle me -- that's how I understood your repeated
assertions
about how simple the problem was. I thought that your purpose was to
belittle me
because I couldn't see another reason for you to stress the fact that
the problem is simple.

I am happy to accept that that was not your intention however.

Paul Epstein
Oct 5 '07 #11
On Oct 6, 12:40 am, pauldepst...@att.net wrote:
"Chris ( Val )" <chris...@gmail.comwrote:
I did not abuse you, try to belittle you, nor make
any claims that the example code I provided was the
right solution for you.
Please take these facts into consideration when
responding to people who are trying to help you
in the future.
--
Chris Val- Hide quoted text -

No, you did not abuse me, but I certainly _did_ think that you were
trying to belittle me -- that's how I understood your repeated
assertions
about how simple the problem was. I thought that your purpose was to
belittle me
because I couldn't see another reason for you to stress the fact that
the problem is simple.
No, it was not my intention to belittle you in any way shape
or form.
I am happy to accept that that was not your intention however.
Glad to hear :-)

Cheers,
Chris Val

Oct 6 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: aundrenash | last post by:
Hello, I'm a beginning graphic/web designer. I created a website with a background graphic that is 800x640 pixels. The problem is on my screen it fits like it should (no scrolling necessary etc.)...
5
by: Last Timer | last post by:
I encountered the following code in Bruce Eckel's online book. Can you please clarify what "const char* const data;" means? Thanks //: C01:MyError.cpp {RunByHand} class MyError { const char*...
5
by: Lionel B | last post by:
Greetings, I am trying to implement "element-wise" arithmetic operators for a class along the following lines (this is a simplified example): // ----- BEGIN CODE ----- struct X { int a,b;
29
by: Merrill & Michele | last post by:
I'm now looking at page 115 K&R. After having discussed counterexamples, I shall herewith and henceforth make all my c programs look like int main(int orange, char* apple) {return(0);} Q1) ...
0
by: Geoffrey L. Collier | last post by:
I wrote a bunch of code to do elementary statistics in VB, and would prefer to find code in C# to recoding all of the VB code. A search of the web found very little. Does anyone know of a good...
4
by: Jamiil | last post by:
I have a class which only purpose is to provide services to a variety of classes in other files. The 'manipulator' class is aware of the other classes only because the header files have been...
9
by: Let_Me_Be | last post by:
Hi all, I'm developing a small defensive programming toolkit for my own projects. So, here are my questions. 1) Is it possible to move from something like this: SAFECALL(foo();) to __safecall...
5
by: bromio | last post by:
can someone help me to make code for digital clock using AT89S52. The specs of clock are 12 hour clock,am-pm display,use timer interrupts to have delay.two external inputs to adjust hours and...
5
by: shylubaskar | last post by:
What does this statement actually mean #include<stdio.h> what is this # stands for
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.