C :: Can Get Memory Addresses From Compile Time?

Sep 1, 2013

My question is this: Is it possible to determine where functions are stored at compile time, so that at run time you can pass the memory address as a pointer to the interrupt handler so that it can directly call the function at memory location 'X'?

The newest project I'm working on would require to either somehow capture these addresses or to find a work-around so that instead of passing the pointer to the interrupt handler, the software would then need to be able to be non-interruptable.

View 2 Replies


ADVERTISEMENT

C++ :: Compare Memory Addresses On The Stack?

Dec 4, 2014

Jumping into C++, question 5 page 181:

"Write a program that compares the memory addresses of two different variables on the stack and prints out the order of the variables by numerical order of their addresses.

Does my solution look correct

Code:
#include <iostream>
using namespace std;
int main() {
int one = 1;
int two = 2;
if (&one < &two)
cout << one << " " << &one << " " << two << &two << endl;
else
cout << two << " " << &two << " " << one << " " << &one << endl;
}

View 6 Replies View Related

C++ :: Memory Addresses Of Pointers To Structs

Apr 19, 2014

I have this struct declaration to create a linked list

struct node {
string y;
node* next;
};

If I create a linked list of 3 nodes

A->B->C->NULL

A->y is "a"
B->y is "b"
C->y is "c"

Since they are consecutive in memory. How far apart are the strings in memory?

I tried doing something like

int n = &(head->next->x)-&(head->x);

The problem is that I got 6 while debugging and 2 otherwise.

View 1 Replies View Related

C++ :: Initializing Pointers To Memory Addresses Or Values?

Aug 31, 2014

What is the difference between initializing pointers to a memory address using the address operator like int *pointer = &x; or initializing it to a value like int *pointer = x; .. in other words how does p and q point to the same memory address in:

const int ARRAY_LEN = 100;
int arr [ ARRAY_LEN ];
int *p = arr;
int *q = &arr[0];

View 4 Replies View Related

C++ :: Program That Prints Out Memory Addresses Of Each Element In Two Dimensional Array

Jun 21, 2013

the question is; Write a program that prints out the memory addresses of each element in a two-dimensional array. Check to see if the values printed out make sense to you based on the way I explained it before.

Below is the code I have done. I am having problems printing the "-" sign to keep formatting with the board when the user enter in different dimensions other than [4][4].

Code:

#include <iostream>
using namespace std;
void printTable (int x, int y) {
int **p_p_twoDimension = new int* [y];
for (int i = 0; i < y; i++) {
p_p_twoDimension[i] = new int [x];}

[Code]...

View 12 Replies View Related

C++ :: Possibility Of Compile Time Calculation

May 13, 2013

Is there any possible way of calculating some values at compile time? I have the following code of genereting upto 2000000010 palindrome numbers.

Code:
#include <iostream>
#include <string>
#include <sstream>
#include <string.h>
#include <stdlib.h>

[Code] .....

As you see, I have taken input from the user just after calculating the whole palindromes. So cant we calculate this at compile time? because runtime of this program is extremely slow.

Another qs. I first tried to use array but It didnt allow 2*10^9 sized array. so what should I do whenever I need that size of array?

View 12 Replies View Related

C++ :: Compile Time Unique Identifier?

Jan 18, 2012

Would there be anyway for the compiler, or the language, to provide a unique ID during compilation?

I've been using UUID generators, but I've always found the approach of copy pasting from a program to code to be kind of... limiting. If I want a random number, can't the compiler guarantee this for me?

It already does the same thing for anonymous namespaces, so...

View 6 Replies View Related

C++ :: Compile-time Loop Loops Wrong

Apr 10, 2013

Consider:
Code: template<unsigned int N>
class Test
{
private:

[Code]....

I just cannot understand why (clearly, we are calling <0, 0>, not <0, 8>). If I replace "N" with 8, it works as expected (at least for the beginning of the loop). I only tested on MSVC.

View 5 Replies View Related

C :: How To Exclude Function Dynamically On Compile Time

Mar 6, 2013

I am working on a project, where I have to be able to exclude some code fast and dynamicly at compiletime.

I got a scheduler running and actually I just want to remove some of the tasks from it - but at compile time so that the code wont take up space in my microcontroller.

I know that I can use macros like #ifdef #endif etc. But I think that method makes the code unreadable and complicated.

How to archive such functionality a more elegant way?

View 1 Replies View Related

C :: Library Of Functions - Getting Error At Compile Time

Nov 19, 2013

So I made a library for a whole bunch of functions and when i compile it, it says"Unresolved external symbol_(Name of function here) referenced in function main.

View 1 Replies View Related

C :: Possible To Create Char String At Compile Time?

Mar 28, 2014

I would like to have a program with a 5 mb string embedded in it kind of like this:

Code:

const char *c;
c = (const char*)"BEGIN_STRING_HERE, (5 MB of arbitrary values here)";

Is it possible to generate this string at compile time? Maybe with a macro? I'm trying to avoid a source file with a 5 mb string in it.

View 3 Replies View Related

C++ :: Set Array Size At Compile Time Through Constructor

Oct 22, 2013

How do I set the size of a member array via the class constructor if I know the size at compile time. I can do this with templates, see below, but this leads to code bloats, I think.

So one class declaration but objects with different array sizes.

Can't use constexpr.
Can't use STL.
Can't use new.

#include <iostream>
using namespace std;
template<int T>
class MyArray {
private:
int array[T];
public:
int getSize()

[Code] ....

View 15 Replies View Related

C++ :: Obtaining Operator From Compile-time Constant?

Nov 5, 2014

I want to generalize my productFunction below to a template family of functions where the template merely changes the * to + or whatever else operator I wish to use.

#include <iostream>
#include <functional>
#define show(variable) std::cout << #variable << " = " << variable << std::endl;
template <typename, typename...> struct ProductFunction;
template <typename RETURN_TYPE, typename FIRST, typename... REST>
struct ProductFunction<RETURN_TYPE, FIRST, REST...> : ProductFunction<RETURN_TYPE, REST...> {
const FIRST function;
using Base = ProductFunction<RETURN_TYPE, REST...>;

[code].....

How can I turn a template parameter into various operators? (apart from using switch statements that will reduce the performance and make the code really ugly) What kind of metatemplating method converts a compile-time constant to an operator?

View 3 Replies View Related

Visual C++ :: Compile Time Errors For OpensSSL In Project

Feb 4, 2014

I am trying to build a VC++ project in Visual Studio 2010. [URL] ....

This project has a dependency on openssl libraries. How can I successfully build this project? How to add third party libs/dlls in a project.

View 1 Replies View Related

C :: Correct Way To Initialize Typedef Structure In Compile Time (with Code)

Mar 6, 2015

Code:
typedef struct token
{
int tokenType; // what token is that
int tokenCode; // the code of a function if applicable
char *tokenString; // Source token
double tokenValue; // if token is a number

[Code] .....

I got several warnings and erros, is it possible to declare a table like that ? What's the correct way to declare it ?

View 4 Replies View Related

C++ :: Memory Allocated To Vector At Certain Point In Time?

May 7, 2013

I have a pretty big std::vector<matrix>, where matrix is a custom class defined by me. I would like to know how much memory has been allocated to that vector at a certain point in time. Is there any way of doing this in c++?

Or is my only shot, taking a look at the task monitor of windows/unix/whatever at execution time to estimate this?

View 2 Replies View Related

C :: Call Only One Time Malloc At The Start Of Program - Memory Size Is Growing

Jan 26, 2013

I have a program which call only one time malloc at the start of the program. When running, I see with 'process-explorer.exe' that memory is growing in little steps. Is this normal? why?

Using Windows 7

View 5 Replies View Related

C :: Check Addresses On Equality Possible?

Sep 18, 2014

I was wondering if it is possible to check if two addresses, so pointers are equal.I was saving the address of an array, and later wanted to identify it by the address, so if my area has the address: int *my_array; // is equal to: 0x1e9aa3a2c ...Later when I go through a list of pointers like:

list=
0x1e9c7e060
0x1e9ba6640
0x1e9aa3a2c <== my address
0x1e9aa3a2c

I want the third one to be equal to my list, but with == it didn't work for me.

View 3 Replies View Related

C# :: Looping Through A Range Of IP Addresses

Feb 6, 2014

I want to take a starting IP on a local network, and loop through to an ending IP on a local network, pinging all the IP addresses in between. For instance, ping all IP addresses between 192.168.1.1 - 192.168.1.255 (user enters desired starting IP and ending IP in text boxes).

I have the ping functionality working, and i can make it all work with lots of messy string parsing.. but it seems sloppy to me.

I have to split the strings (start and end IP) to get the last octet, then subtract to get the range of IPs. Then loop through, adding 1 to the last octet, and converting back to a string each time.

The C# Ping class can use either a string or an IPaddress for its Send method. If I use IPAddress, I just have to convert it from the text box it originates in, but the adding 1 to the last octet in the loop is a hassle.

Anyway, I guess the only question I have is, if you had to loop through a range of IP addresses, how would YOU do it?

public Job(string ipStartIn, string ipEndIn) {
long ip1 = Convert.ToInt64(ipStartIn);
long ip2 = Convert.ToInt64(ipEndIn);
IPStart = new IPAddress(ip1);
IPEnd = new IPAddress (ip2);
this.deviceAlive = false;

[Code] ....

View 14 Replies View Related

C/C++ :: Hashing Hexadecimal Addresses?

Feb 25, 2015

I'm taking a university course and one of our first projects dealing with C is to write a hash table (with chaining as a collision solution) that will hash loads of hexadecimal values into the table. I'm just brain storming right now but how practical is it to hash the values by converting them to decimal and working with that value in another function to organize the values? I'm thinking this might take a lot of time and memory because our code will be tested with text files that could have a few lines of hexadecimal addresses or millions of them.

View 2 Replies View Related

C++ :: Define Statement Assigning Addresses

Sep 10, 2013

I dont understand the pointers or the parenthesis.

#define PORTA *(unsigned char volatile *)(0x0000)

View 2 Replies View Related

C/C++ :: Passing Structure Addresses To Functions

Mar 20, 2014

What this is, is a more recent assignment and my question is if my errors are directly related to passing structure addresses to functions. I've tried several syntax variations at the beginning of my loops such as this one:

while (choice != "Q" || "q")

But the loops will not run since I introduce polar to rectangular and the choice element. My last working code was rectangular to polar and all of it worked fine.

#include<iostream>
#include<cmath>
using namespace std;
//structure declarations
struct polar
{
double distance; //distance from origin
double angle; //direction from origin

[Code] ....

View 14 Replies View Related

C++ :: Way To Use Debugger To Log Addresses Of Data It Allocated On Heap

Sep 19, 2014

I used a heap viewer to check for memory leaks. I have many of them and its hard to find out where it is not being freed. Is their a way to use the debugger to log the addresses of the data it allocated on the heap. This way I can trace it back. Or is their any other way to fix memory leaks properly.

View 4 Replies View Related

C :: Save Data To Arrays Defined In Main Using Their Addresses

Dec 30, 2013

so i have two classes ( main and another one ask ) in main i have defined 3 arrays (char drivers[250] ,offences[250] , owners[250]) and also included their pointers ( char *drivers_ptr,*offences_ptr,8owners_ptr)my problem is that i need to set values (actually 1 string of 250 chars to each of these arrays BUT from the class ask without making these arrays global -as this is prohibited by my university exercise !- )

so my question is how will i manage to save data to the arrays that i have defined in main using their addresses(through the pointers of each one that i have passed to the ask class) from the ask class ?

View 4 Replies View Related

Visual C++ :: TCP/IP Program - Display All IP Addresses That Are Connected To Client

Mar 12, 2013

I need to create a TCP/IP program using visual studios MFC that displays all client's IP addresses that are connected to the client.

The MFC application just has a list box and a button. The client can be a simple console application. When the button is clicked, the list box gets populated with all ip addresses of connected clients.

View 14 Replies View Related

C++ :: Iterate Through Char Array And Pull IP Addresses To Test If They Respond

Apr 8, 2013

I am trying to write a loop that will iterate through a char array in C and pull the IP addresses and test them to see if they respond. My ultimate goal is to have the first one that responds returned in the function, but the loop is not running correctly. It will run through right the first time, but then will start over again.

Code:
const char * getServer(char *svrList) {
char *srList;
srList = strtok(svrList, " ," );
printf("Contents of srList b4 loop: %s
", srList);
printf("Server List: %s
", svrList);

[Code] ....

Code output:
Contents of srList b4 loop: 1.1.1.1
Server List: 1.1.1.1
result is "1.1.1.1"
Hitting else loop
Contents of srList in else: 2.2.2.2
result is "2.2.2.2"
result is "2.2.2.2"
Contents of srList b4 loop: 1.1.1.1
Server List: 1.1.1.1
result is "1.1.1.1"
Hitting else loop
Contents of srList in else: (null)

View 14 Replies View Related







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