Sponsored Content
Homework and Emergencies Emergency UNIX and Linux Support Functions defined in header / cpp file behaves different Post 302448930 by uunniixx on Friday 27th of August 2010 12:27:23 PM
Old 08-27-2010
Functions defined in header / cpp file behaves different

File: A.h

Code:
class A
{
  public:
  struct x X;
  int show()
  {
    x.member_variable ? 0: -1;
  }
};

Now if A.cpp is complied which includes A.h (which is actually in a huge project space) we see that x.member_variable value is not as expected. But if remove the show() method and place it in A.cpp the code behaves fine - meaning that x.member_variable value is correct.

How such a thing may happen - one thing we saw from objdump is that if the function is defined in A.h the the method is treated as inline function which otherwise is not if defined in A.cpp?

How the code can behave differently altogether?

Last edited by Scott; 08-27-2010 at 03:13 PM.. Reason: Added code tags
 

10 More Discussions You Might Find Interesting

1. Linux

Reading the header of a tar file(posix header)

say i have these many file in a directory named exam. 1)/exam/newfolder/link.txt. 2)/exam/newfolder1/ and i create a tar say exam.tar well the problem is, when i read the tar file i dont find any metadata about the directories,as you cannot create a tar containig empty directories. on the... (2 Replies)
Discussion started by: Tanvirk
2 Replies

2. Shell Programming and Scripting

If file = .cpp then print?

I'm trying to develop a script that makes it so only .cpp programs can print. I'm doing it for my computer programming class because everyone keeps printing the executable instead of the source code and it's wasting a lot of paper. How can I accomplish this? Thanks for the help. :D (5 Replies)
Discussion started by: Irish_Cereal
5 Replies

3. Shell Programming and Scripting

reading a cpp file

I need to find all the methods in a cpp file ... using shell script Pls guide me regarding the grep criteria for searching methods I mean what are the patterns to be grepped in *.cpp which match methods Hope i have made myself clear Thanks and Regards -- Ultimatix (2 Replies)
Discussion started by: ultimatix
2 Replies

4. Shell Programming and Scripting

want to find out a function name in a cpp file

I have an error in my logs as it shows some function name . 1. I dnt know where is the file.cpp located only i know the machine . 2. How to find out that the function name is loacated in which path and which file into that machine. Thanks . (1 Reply)
Discussion started by: madfox
1 Replies

5. Shell Programming and Scripting

user-defined functions, "$@", $jobs and $ps wwaxu

Imagine a user-defined function. func() { /usr/pkg/bin/program long-string-of-switches-and-configs "$@" ;} I execute it once. Then background it. I execute another instance. Then bg it. func unique-user-input ^Z func unique-user-input ^Z First I view with ps ps wwaux ... (0 Replies)
Discussion started by: uiop44
0 Replies

6. Shell Programming and Scripting

User defined functions in awk

Hi; Is der ne to to use user defined functions for the values in awk find $1 -type f -ls | nawk '{{print "|"$3"|"$5"|"$6"|"$8"|"$9"|"$10"|"} for(i=11;i<=NF;i++){printf("%s",$i)}}' In above command i want to append some values returned by user functions on line. thnks; ajay (1 Reply)
Discussion started by: ajaypadvi
1 Replies

7. Shell Programming and Scripting

[solved] awk: placement of user-defined functions

Hi folks, is there any recommendation, especially from a point of performance, about where to place a user-defined function in awk, like in BEGIN{} or if it is only need once at the end in END{}? Or doesn't it matter at all since, awk is so clever and only interprets it once, wherever it is... (3 Replies)
Discussion started by: zaxxon
3 Replies

8. UNIX for Dummies Questions & Answers

Error in compiling .cpp file

I get this error, defaults.cpp: In member function ‘int Defaults::GetIntDefault(const std::string&)’: defaults.cpp:68: error: ‘atoi’ was not declared in this scope defaults.cpp: In member function ‘real_t Defaults::GetRealDefault(const std::string&)’: defaults.cpp:76: error: ‘atof’ was not... (1 Reply)
Discussion started by: bstephens
1 Replies

9. Shell Programming and Scripting

Mkdir fails when defined and called with functions.

In the below script i found that the alias mkdir_s is getting invoked from function configure() i.e the alias is kicking in. #!/bin/bash -e shopt -s expand_aliases alias mkdir=mkdir_s mkdir_s(){ if ]; then return else /usr/bin/mkdir "$1" return fi } configure() { mkdir -p... (9 Replies)
Discussion started by: mohtashims
9 Replies

10. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies
zipios::ZipOutputStream(3)				     Library Functions Manual					zipios::ZipOutputStream(3)

NAME
zipios::ZipOutputStream - SYNOPSIS
#include <zipoutputstream.h> Public Member Functions ZipOutputStream (std::ostream &os) ZipOutputStream constructor. ZipOutputStream (const std::string &filename) ZipOutputStream constructor. void closeEntry () Closes the current entry updates its header with the relevant size information and positions the stream write pointer for the next entry header. void close () Calls finish and if the ZipOutputStream was created with a filename as a parameter that file is closed as well. void finish () Closes the current entry (if one is open), then writes the Zip Central Directory Structure closing the ZipOutputStream. void putNextEntry (const ZipCDirEntry &entry) void putNextEntry (const std::string &entryName) void setComment (const std::string &comment) Sets the global comment for the Zip archive. void setLevel (int level) Sets the compression level to be used for subsequent entries. void setMethod (StorageMethod method) Sets the compression method to be used. virtual ~ZipOutputStream () Destructor. Detailed Description ZipOutputStream is an ostream that writes the output to a zip file. The interface approximates the interface of the Java ZipOutputStream. Definition at line 18 of file zipoutputstream.h. Constructor &; Destructor Documentation zipios::ZipOutputStream::ZipOutputStream (std::ostream &os) [explicit] ZipOutputStream constructor. Parameters: os ostream to which the compressed zip archive is written. pos position to reposition the ostream to before reading. Definition at line 13 of file zipoutputstream.cpp. zipios::ZipOutputStream::ZipOutputStream (const std::string &filename) [explicit] ZipOutputStream constructor. filename to write the zip archive to. Definition at line 24 of file zipoutputstream.cpp. zipios::ZipOutputStream::~ZipOutputStream () [virtual] Destructor. Definition at line 74 of file zipoutputstream.cpp. Member Function Documentation void zipios::ZipOutputStream::close () Calls finish and if the ZipOutputStream was created with a filename as a parameter that file is closed as well. If the ZipOutputStream was created with an ostream as its first parameter nothing but the call to finish happens. Definition at line 38 of file zipoutputstream.cpp. void zipios::ZipOutputStream::closeEntry () Closes the current entry updates its header with the relevant size information and positions the stream write pointer for the next entry header. Puts the stream in EOF state. Call putNextEntry() to clear the EOF stream state flag. Definition at line 33 of file zipoutputstream.cpp. void zipios::ZipOutputStream::finish () Closes the current entry (if one is open), then writes the Zip Central Directory Structure closing the ZipOutputStream. The output stream that the zip archive is being written to is not closed. Definition at line 45 of file zipoutputstream.cpp. void zipios::ZipOutputStream::putNextEntry (const ZipCDirEntry &entry) Begins writing the next entry. Definition at line 50 of file zipoutputstream.cpp. void zipios::ZipOutputStream::putNextEntry (const std::string &entryName) Begins writing the next entry. Definition at line 54 of file zipoutputstream.cpp. void zipios::ZipOutputStream::setComment (const std::string &comment) Sets the global comment for the Zip archive. Definition at line 59 of file zipoutputstream.cpp. void zipios::ZipOutputStream::setLevel (intlevel) Sets the compression level to be used for subsequent entries. Definition at line 64 of file zipoutputstream.cpp. void zipios::ZipOutputStream::setMethod (StorageMethodmethod) Sets the compression method to be used. only STORED and DEFLATED are supported. Definition at line 69 of file zipoutputstream.cpp. Author Generated automatically by Doxygen for Zipios++ from the source code. Zipios++ Mon Oct 10 2011 zipios::ZipOutputStream(3)
All times are GMT -4. The time now is 10:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy