473,320 Members | 1,831 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,320 software developers and data experts.

C and C++ naming issues?

http://www.gubbe.ch/code/libcfgparse...8h-source.html

That page contains a header that when included does not define any of
the typedefs or any of the value references that are in that file. For
instance, I included that file and then tried this:

switch (file.get_type("valid_operating_systems"))
{
case CFG_ITEM_NONE: cerr << "NONE" << endl; break;
case CFG_ITEM_INTEGER: cerr << "INT" << endl; break;
case CFG_ITEM_BOOLEAN: cerr << "BOOL" << endl; break;
case CFG_ITEM_FLOATINGPOINT: cerr << "FLOAT" << endl; break;
case CFG_ITEM_STRING: cerr << "STR" << endl; break;
case CFG_ITEM_CONTAINER: cerr << "CONTAINER" << endl; break;
default: cerr << "WHO THE FUCK KNOWS?!" << endl;
}

When compiled with g++ I get an error saying that none of those
identifiers exist. But they are quite obviously defined right there in
the file I included! If I copy the definition for CfgItemType into my
source file it compiles just fine. I would really like to understand
what the hell is going on here if anyone can figure that out.

Thanks.

Jul 23 '05 #1
13 1227
Noah Roberts wrote:
http://www.gubbe.ch/code/libcfgparse...8h-source.html

That page contains a header that when included does not define any of
the typedefs or any of the value references that are in that file. For
instance, I included that file and then tried this:

switch (file.get_type("valid_operating_systems"))
{
case CFG_ITEM_NONE: cerr << "NONE" << endl; break;
case CFG_ITEM_INTEGER: cerr << "INT" << endl; break;
case CFG_ITEM_BOOLEAN: cerr << "BOOL" << endl; break;
case CFG_ITEM_FLOATINGPOINT: cerr << "FLOAT" << endl; break;
case CFG_ITEM_STRING: cerr << "STR" << endl; break;
case CFG_ITEM_CONTAINER: cerr << "CONTAINER" << endl; break;
default: cerr << "WHO THE FUCK KNOWS?!" << endl;
}

When compiled with g++ I get an error saying that none of those
identifiers exist. But they are quite obviously defined right there in
the file I included! If I copy the definition for CfgItemType into my
source file it compiles just fine. I would really like to understand
what the hell is going on here if anyone can figure that out.


I believe the answer is in the FAQ 5.8. Find the FAQ by following this
link: http://www.parashift.com/c++-faq-lite/

V
Jul 23 '05 #2

Victor Bazarov wrote:
I believe the answer is in the FAQ 5.8. Find the FAQ by following this link: http://www.parashift.com/c++-faq-lite/


I don't think so, smartass.

Jul 23 '05 #3
I have figured out what is going on. Thanks anyway.

Jul 23 '05 #4
"Noah Roberts" <nr******@stmartin.edu> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
I have figured out what is going on. Thanks anyway.


I did spend some time trying to figure out your problem. Would you please
let us know what it was...

Thank you,
Ali

Jul 23 '05 #5
Noah Roberts wrote:
Victor Bazarov wrote:

I believe the answer is in the FAQ 5.8. Find the FAQ by following


this
link: http://www.parashift.com/c++-faq-lite/

I don't think so, smartass.


Do they teach you that language at Saint Martin's or are you just
naturally so sweet?
Jul 23 '05 #6

Ali Çehreli wrote:
"Noah Roberts" <nr******@stmartin.edu> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
I have figured out what is going on. Thanks anyway.

I did spend some time trying to figure out your problem. Would you

please let us know what it was...


The file was being included by another file which was wrapping it in a
namespace. When I included it after the fact the #ifdef protection of
course kept anything in that file from being included because it
already was...but in a namespace.

How common is that when dealing with C++ wrapped libraries? I don't
like it...I think there should be

#ifdef __cplusplus
namespace x {
#endif

in any file that is going to be used in C++ that should be in a
namespace when so used.

Thanks for trying to figure out the problem. In my opinion the problem
was poor header design.

I figured it out when trying to pass one of those identifiers as a
parameter to a function that was set to accept only those values. Got
one of these:

test_cfg.cpp: In function `int main()':
test_cfg.cpp:116: no matching function for call to
`Cfg::Container::Container(
CfgContainerType)'
C:/msys/1.0/local/include/cfgparse/container.hpp:78: candidates are:
....
C:/msys/1.0/local/include/cfgparse/container.hpp:57:
Cfg::Container::Container(Cfg::CfgContainerType)

And that pretty much told me what was wrong.

Jul 23 '05 #7
Noah Roberts wrote:

Victor Bazarov wrote:
I believe the answer is in the FAQ 5.8. Find the FAQ by following

this
link: http://www.parashift.com/c++-faq-lite/


I don't think so, smartass.


And that'll be *plonk* for you.


Brian
Jul 23 '05 #8
On 28 Feb 2005 14:16:33 -0800, "Noah Roberts" <nr******@stmartin.edu>
wrote:

Victor Bazarov wrote:
I believe the answer is in the FAQ 5.8. Find the FAQ by followingthis
link: http://www.parashift.com/c++-faq-lite/


I don't think so, smartass.


In section 5.8:
2. Post complete code: put in all necessary #includes and declarations
of needed types and functions


As you mentioned in another posting, you had an include file being used
that was wrapped in a namespace. Providing this information to the group
would have allowed the problem to be solved much more quickly (if it wasn't
solved on the spot.)
Jul 23 '05 #9

Raymond Martineau wrote:
As you mentioned in another posting, you had an include file being used that was wrapped in a namespace. Providing this information to the group would have allowed the problem to be solved much more quickly (if it wasn't solved on the spot.)


Very well. Next time I will make sure to paste my entire program and
the source for all libraries and header files as well. I am sure that
will make it much easier to diagnose any problems.

Unfortunately it looks like my last post got lost. Oh well.

Man, you guys need something better to do. You are wound WAY too
tight. I just don't have the patience.

Jul 23 '05 #10
Noah Roberts wrote:
[..] I just don't have the patience.


Isn't that the real problem here?
Jul 23 '05 #11
"Noah Roberts" <nr******@stmartin.edu> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...

Raymond Martineau wrote:
As you mentioned in another posting, you had an include file being
used that was wrapped in a namespace. Providing this information
to the group would have allowed the problem to be solved much
more quickly (if it wasn't solved on the spot.)

Quite true and good input at this point.
Very well. Next time I will make sure to paste my entire program and
the source for all libraries and header files as well. I am sure that
will make it much easier to diagnose any problems.
Please try to suppress your more juvenile responses
and consider why the expectations here differ from
what you have done. It is a mistake to think of this
forum as simply a free help center.

People are commonly asked to provide a minimal
but complete program that demonstrates the problem
they are asking about. If you had done this, you could
have found your problem without posting anything.
Posting a whole, unreduced project will lead only to
some wasted storage and time. And it tells those who
might help you that you are not interested in helping to
solve your own problem. When I see that, my interest
dwindles rapidly to none.
Unfortunately it looks like my last post got lost. Oh well.
As far as I can see, this has about as much meaning to
the other participants here as if you had announced
that you once had an itch and got it scratched.
Man, you guys need something better to do. You are wound
WAY too tight. I just don't have the patience.


If you continue on your present trend, you are
likely to find that the feeling has become mutual.

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.
Jul 23 '05 #12

Larry Brasfield wrote:
It is a mistake to think of this
forum as simply a free help center.


I have frequented this particular newsgroup for many years. I know
what it is. Thanks anyway.

Jul 23 '05 #13
Noah Roberts wrote:
How common is that when dealing with C++ wrapped libraries? I don't
like it...I think there should be

#ifdef __cplusplus
namespace x {
#endif

in any file that is going to be used in C++ that should be in a
namespace when so used.


Doesn't sound like a good idea to me. It should often be the _user_ of
such a library that needs to distinguish between the different libraries
used when they share some common names or definitions. Otherwise, what
if two library creators both decide to use the same namespace, and
happen to also collide on some identifier names?

IMHO, much better when I can say something like this in my code:

-----
namespace win32 {
#include <windows.h>
}
namespace mailer {
#include "somevendor.h"
}

::
win32::PostMessage(wnd_handle, mymsg, 1, 5);
mailer::PostMessage(recipient, mymsg, 1, 5);
-----

--
-+-Ben-+-
Jul 23 '05 #14

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

Similar topics

4
by: VK | last post by:
09/30/03 Phil Powell posted his "Radio buttons do not appear checked" question. This question led to a long discussion about the naming rules applying to variables, objects, methods and properties...
4
by: VM | last post by:
What's the correct variable naming in C#? How should a form be called (eg. Frm_myForm)? or an int variable (eg. Int_Var) or a DataGrig (eg. DG_myGrid)? I'm writing an application but I would like...
5
by: Marco Solchio | last post by:
I'm coming from C++ world, where I've been using #define SALSA 1 and #define SALSA_DANCE "Salsa Dance" in a header file to define my constants..., all uppercase and underscores. Does the...
3
by: clintonG | last post by:
Does the use of DTD, XML Schema and similar constructs adopt the use of C# naming conventions? If so how do I make the distinction of how to apply C# conventions with XML elements, attributes and...
3
by: Phillip Conrad | last post by:
Here is a little problem I've run into, and none of the naming conventions have helped... Ever since I switched from C to C# and FxCop, I've going crazy trying to fix some style issues. I have 3...
114
by: Jonathan Wood | last post by:
I was just wondering what naming convention most of you use for class variables. Underscore, "m_" prefix, camel case, capitalized, etc? Has one style emerged as the most popular? Thanks for...
5
by: Allen | last post by:
Yesterday I discussed with my boss about method naming. In the RPC argument pack / unpack classes, packing & unpacking remote procedure calling arguments into / from a byte buffer. I named the...
14
by: Ronald S. Cook | last post by:
I've been weaning myself off of Hungarian notation because that's what Microsoft is telling me to do, and I want to be a good little MS developer. But things keep coming up that make me miss my...
2
by: cj | last post by:
I run two instances of an application on a pc at one time. I want them to assume app A and app B identities. If I check for a previous instance of the app running when the app starts I can...
8
oll3i
by: oll3i | last post by:
it worked but suddenly when i run it and click a button it throws exception ? D:\SR>java Producent queue1 queue2 queue3 queue4 queue1,queue2,queue3,queue4...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.