473,326 Members | 2,127 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,326 software developers and data experts.

variables & method naming conflicts

Hi Gurus,
I got a problem, I am trying to port a win32 prog to Linux. It was all
one big program.cpp and I have to split the functions into separate
init_pxi6052e.cpp,func1.cpp and func2.cpp in order to compile them
separately and debug them. In both cpp file I have to include a common
header file lets call it here as "datatype.h" which is included in both
"init_pxi6052e.cpp" and "test_init_boards.cpp". Both these object
compiles ok. SEe here
%g++ -c test_init_boards.cpp
%g++ -c init_pxi6052e.cpp
However it screws up where I try to link them together to an
executable.

%g++ -o test_init_boards test_init_boards.o init_pxi6052e.o
callback_everyn.o -lnidaqmx
init_pxi6052e.o(.bss+0x20): multiple definition of `InputDataBuffer'
test_init_boards.o(.bss+0x20): first defined here
init_pxi6052e.o(.bss+0x24): multiple definition of `OutputDataBuffer'
test_init_boards.o(.bss+0x24): first defined here
init_pxi6052e.o(.bss+0x40): multiple definition of `msg'
test_init_boards.o(.bss+0x40): first defined here
.... [many lines more here]

I am mixing some C header files in the "datatype.h" files. What is the
best ways to handle this? Please help!

Feb 27 '06 #1
2 1751
Joseph wrote:
Hi Gurus,
I got a problem, I am trying to port a win32 prog to Linux. It was all
one big program.cpp and I have to split the functions into separate
init_pxi6052e.cpp,func1.cpp and func2.cpp in order to compile them
separately and debug them. In both cpp file I have to include a common
header file lets call it here as "datatype.h" which is included in both
"init_pxi6052e.cpp" and "test_init_boards.cpp". Both these object
compiles ok. SEe here
%g++ -c test_init_boards.cpp
%g++ -c init_pxi6052e.cpp
However it screws up where I try to link them together to an
executable.

%g++ -o test_init_boards test_init_boards.o init_pxi6052e.o
callback_everyn.o -lnidaqmx
init_pxi6052e.o(.bss+0x20): multiple definition of `InputDataBuffer'
test_init_boards.o(.bss+0x20): first defined here
init_pxi6052e.o(.bss+0x24): multiple definition of `OutputDataBuffer'
test_init_boards.o(.bss+0x24): first defined here
init_pxi6052e.o(.bss+0x40): multiple definition of `msg'
test_init_boards.o(.bss+0x40): first defined here
... [many lines more here]

I am mixing some C header files in the "datatype.h" files. What is the
best ways to handle this? Please help!


What are InputDataBuffer, OutputDataBuffer and msg? Are they types? Global
variables? Where are they defined? In the cpp files or in the header? Where
is their declaration?

Feb 27 '06 #2
JE

Joseph wrote:
<snip>
I have to include a common
header file lets call it here as "datatype.h" which is included in both
"init_pxi6052e.cpp" and "test_init_boards.cpp". <snip> multiple definition of

<snip whatever>

Maybe you've got globals that violate the "One Definition Rule" in
header(s)? Make sure you've got extern whatever in the header (_not_
initialized, because that would be a definition) for your declaration,
and _one_ definition in one of your .cpp files...

JE

Feb 27 '06 #3

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

Similar topics

0
by: JShurmatz | last post by:
If anyone can shed some light on this problem I would greatly appreciate it. I am unsuccessfully trying to use a database connnection retrieved from a pool configured using Java System Web...
3
by: John Salerno | last post by:
Does Microsoft have any naming guidelines for variables? I've been reading their guidelines for just about every other type (methods, parameters, properties, etc.) but nothing about variables. Are...
3
by: Adam Knight | last post by:
Hi all, Can I have a class that contains a IsDirector Method & IsDirector property. The method populates the property. I have tried the code below..but get a 'definition for IsDirector'...
2
by: John Salerno | last post by:
After reading the PEP, I'm still not quite sure if there is a recommended (or widely preferred) method of naming variables. Here are the relevant bits: > Global Variable Names > > (Let's...
2
by: Rob Long | last post by:
Hi there Is there any way to access private variables directly from within a priviliged function? I have a situation where the priviliged function's execution context contains variables of the...
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...
0
by: Zytan | last post by:
http://msdn2.microsoft.com/en-us/library/system.exception.data(VS.80).aspx says: "Avoid key conflicts by adopting a naming convention to generate unique keys for key/value pairs. ... two...
20
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
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: 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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
1
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.