C++ ::  In Function Assignment Makes Pointer From Integer Without A Cast

Jul 4, 2013

The log file gives me: In function ‘memFileAlloc’ assignment makes pointer from integer without a cast..When compiling the drivers for the Matrox card in the DL580. The offending code is:

STACK_LINKAGE MEMHANDLE memFileAlloc(
UINT32 dwSize,
const char* pszFileName,
int iLine) {
void* pvChunk;
#if MEMORY_STATS

[code]...

I think the offending line is:
pvChunk = ClientMemAlloc(dwSize + sizeof(UINT32), NULL)
because that's what the log file tells me.

The system is a 16 core HP DL580 G4 with 8g RAM, RAID 0, Mandrivalinux 11.0 and the display is a Matrox Parhelia 256PCIx.

View 11 Replies


ADVERTISEMENT

C :: Makes Integer From Pointer Without Cast

Mar 18, 2013

The warning: :63:7: warning: passing argument 1 of fputc makes integer from pointer without a cast [enabled by default]

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/stat.h>

[Code]....

View 2 Replies View Related

C++ :: Why Assignment Makes Pointer From Integer

Jul 27, 2013

when i compile the following program i get a compiler warning, but i don't understand why. for me the code seems to be all right and does legitimate this warning. so here is the code

// multiplication.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "crypto.h"
#define PROGNAME "multiplication"
void usage();
int isnumaber(char* str);

[code]....

View 2 Replies View Related

C :: Passing Argument 1 Makes Pointer From Integer Without A Cast

Mar 6, 2015

Code:
#include<stdio.h>
print_int_ptr(int *a){

printf(" a %i
" ,a);
printf(" &a %i
" ,&a);

[Code] .....

I get that warning : passing arg 1 of `print_int_ptr' makes pointer from integer without a cast|

View 3 Replies View Related

C :: Passing Arg 1 Of Strcmp Makes Pointer From Integer Without Cast

Jan 18, 2015

Code:

#include <stdio.h>
int main(){
int a=15 ;
int b =20 ;
strcmp((a, "20") == 0) {
printf("Correct!");

[Code] .....

passing arg 1 of `strcmp' makes pointer from integer without a cast

View 11 Replies View Related

C :: Passing Argument 1 Makes Integer From Pointer Without A Cast

Mar 26, 2014

I am having some errors with pointers and passing arguments.

Code:

#include <stdlib.h>
#include <stdio.h>
#define MAX_FILE_LENGTH 20
typedef struct node_{
int value;
struct node_* next;

[Code]....

View 3 Replies View Related

C :: Warning - Return Makes Pointer From Integer Without A Cast

Sep 21, 2013

I have a function that I want to exit gracefully when an "error" occurs in an input file. My function declaration is:

Code: BSTnode *buildTree(FILE *fp)

The few lines that are causing the problems are:

Code: if(regcomp(®ex, to_find, REG_EXTENDED | REG_NEWLINE) != 0) {
fprintf(stderr, "Failed to compile regex '%s'
", to_find);
return EXIT_FAILURE;
}

I know that if I just use "return" by itself the warning goes away but fails to exit when the error occurs. I also believe this may not be the correct use of stderr. But I need the program to exit when an error has occurred.

View 9 Replies View Related

C :: Making Integer From Pointer Without A Cast

Dec 15, 2013

Code:
#include <stdio.h>
#include <stdlib.h>
#define CLASS 4
#define STUDENT 11
#define GRADE 5

[Code] ....

Giving me that error on 75:10
avesub+=grade[k];
and 90:17
donkeypunch+=grade[j][k];

not sure exactly why

View 8 Replies View Related

C/C++ :: Warning - Cast From Pointer To Integer Of Different Size

Jan 23, 2014

int hash = 0;
char *strings[100];
if((int)strings[i] != 0)
if((int) strings[hash] != 0)
while((int) strings[hash] != 0)
if((int)strings[hash] != 0)
if((int)strings[hash] != 0)

View 12 Replies View Related

C++ :: Member Function Pointer Assignment?

May 15, 2013

I have a class with member functions and a pointer like this:

Code:
class MyClass{
private:
typedef void(MyClass::*memFnPtr_t) ();
public:
memFnPtr_t fnptr;
void fn1();
void fn2();
};

Now in a regular function I create an instance of the class and try to assign the pointer:

Code:
MyClass mc;
mc.fnptr = &mc.fn1;

The compiler does not like it and suggests this instead:

Code:
mc.fnptr = &MyClass::fn1;

This seems to work but what if I have two instances of the class:

Code:
MyClass mc1, mc2;

How does the compiler know to distinguish between

Code:
mc1.fn1

and

Code:
mc2.fn1

when the assignment now looks identical:

Code:
mc1.fnptr = &MyClass::fn1;
mc2.fnptr = &MyClass::fn1;

View 14 Replies View Related

C :: Cast Of The Pointer To Array

Dec 7, 2013

In my refference book I have got a example with a part saying to access the a[4][0] element of the array (named a) with pointer this can be written:

*((int*)a+4)

I wonder if the cast is really required. The book says it is required so that the pointer arithmetic can be done properly. However I am not sure about it. When I work with pointers defined by myself I don't use casts similar to this one. Is there a difference between a self defined pointer and array name?

View 14 Replies View Related

C :: Cast To Character Pointer For Printf

Apr 18, 2014

I cannot get the following to compile. The problem is the printf on the last line. I understand that printf requires a char (or pointer to char). I understand that I can convert between datatypes by putting the target data type in parenthises in front of the variable. But how do I cast the integer into a character and then get it's pointer to pass into printf?

Following is my code. I compile with gcc temp.c -o temp.

Note that I have tried many attempts at that last line and this is just the one that I really, really think should work (or is at least the closest to the correct answer).

This code shown below, using printf("%s", &(char)nextChar); returns

temp.c:26: error: lvalue required as unary '&' operand

If I try to use printf("%s", *(char)nextChar); I get the error

temp.c:26: error: invalid type argument of 'unary *' (have 'int')

This line printf("%s", (char)nextChar); returns the obvious

format '%s' expects type 'char *', but argument 2 has type 'int'

Code:

#include <stdio.h>
int main() {
printf("hello, world
");
#if defined(SUNDIALS_EXTENDED_PRECISION)

[Code] ....

View 5 Replies View Related

C++ :: Linked List Set Function - Forbids Comparison Between Pointer And Integer

May 5, 2014

I'm trying to write a function called 'set' that sets the value of the i'th cell to val on my linkedList, and then returns the previous contents. I am stuck on it due to compiling errors:

This is my Node struct:

#ifndef NODE_H
#define NODE_H
#include <iostream>
template <typename T>
struct Node {
friend std::ostream &operator <<(std::ostream &os, const Node<T> &node) {

[Code] ....

The following is my set function:

template <typename T>
T set(Node<T> *head, int i, const T &val) {
for(int n = 0; n < i; n++)
if(head == val) {
val = i;
} return val;
} #endif

When I try to call it in the main() I get these errors:

node_utils.h: In function ‘T set(Node<T>*, int, const T&) [with T = int]’:
node_demo.cpp:26:38: instantiated from here
node_utils.h:161:2: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
node_utils.h:162:3: error: assignment of read-only reference ‘val’

So, I understand that I can't compare head & val on my if-statement -- But what do I do?

View 7 Replies View Related

C++ :: Cannot Cast From Void Pointer - Returns Always Error C2440

Apr 25, 2013

I having a problem which I'm not able to resovle. I try to dereference a void pointer but I always get a C2440 error. It says: 'static_cast':void* cannot be converted in wqueue<T>. I tried different cast ways but I always get the same error. As far as I found out I should get the error if I try to dereference without cast but in my case I cast before and still get that error.

void *srumbler (void *arg) {
wqueue<workclas*> m_queue= static_cast<wqueue<workclass*>>(arg);
return NULL;
}

The according type wqueue in the header file:

template <typename T> class wqueue {
list<T> m_queue;
pthread_mutex_t m_mutex;
pthread_cond_t m_condv;

[Code] .....

View 3 Replies View Related

C/C++ :: Warning / Assignment From Incompatible Pointer Type

Apr 17, 2014

I'm working on a program and everything works except for the follow function:

void swapHex(int x, int byte1, int byte2) {
unsigned char *b1, *b2, tmpc;
printf("%d in hex is %x
", x, x);
printf("swapping byte %d with byte %d
", byte1, byte2);

[Code] ....

I get the following errors when compiling:

In function "swapHex":
warning: assignment from incompatible pointer type
warning: assignment from incompatible pointer type

View 2 Replies View Related

C++ :: Cast Base Class Pointer To Derived Class Pointer

Feb 6, 2015

I create an instance of a base class (not derived class) and assign it to base class pointer. Then, I convert it to a pointer to a derived class and call methods on it.

why does it work, if there is a virtual table?

when will it fail?

// TestCastWin.cpp : Defines the entry point for the console application.//

#include "stdafx.h"
#include <iostream>
class B
{
public:
B(double x, double y) : x_(x), y_(y) {}
double x() const { return x_; }

[Code] ....

View 14 Replies View Related

C++ :: Create Assignment Operator For A Class That Uses Pointer For Its Private Variable?

Mar 30, 2013

i am trying to create the assignment operator for a class that uses a pointer for it's private variable. The error is saying expected constructor, deconstructor, or type conversion before "operator. (which is the assignment operator. I have tried everything i could think of or find online and nothing has worked. below is the code for the assignment operator in the .h file and the .cpp file.

//Assignment constructor
indexList &operator=(const indexList <T> &rhs);
template <class T>
indexList<T>::indexList operator=(const indexList <T> &rhs) {
if(this != &rhs) {
numberOfElements = rhs.numberOfElements;

[Code]...

View 1 Replies View Related

C++ :: Create A Function That Makes A Copy Of Private Map

Nov 8, 2014

So I'm doing this project: [URL] ....

For now I've done a function that creates menus and prints them, and a function that creates the character as an object.

Now I want to be able to show the stats of the player on the main menu, the problem is that I don't know how to make a copy of the map as it's private...

Main
#include <iostream>
#include <string>
#include <time.h>
#include <stdlib.h>
#include <map>
#include <algorithm>
#include <stdlib.h>
#include "Create_Character.h"
#include "Menu.h"

[Code] ....

View 11 Replies View Related

C++ :: Function That Makes Shows Time Entered In Clock Format

Mar 11, 2014

Program should continually have user enter a positive integer, and quits on zero entered. This entered number represents the total number of seconds and after each number is entered a function is called that displays the time in hours, minutes and seconds. Sample output is as follows:

Enter Total Seconds --> 3605 1:00:05

The function needs only one value parameter and should return nothing back to main. If the minutes or seconds are a one digit number then make sure to display a leading zero as the example above shows.

Here is my program. my question is how do i make the numbers appear like this? 1:00:05

#include <iostream>
#include <iomanip>
using namespace std;

[Code].....

View 6 Replies View Related

C :: Calling Function Via Function Pointer Inside Structure Pointer

Mar 14, 2013

I'm trying to call a function via a function pointer, and this function pointer is inside a structure. The structure is being referenced via a structure pointer.

Code:

position = hash->(*funcHash)(idNmbr);

The function will return an int, which is what position is a type of. When I compile this code,

I get the error: error: expected identifier before ( token.

Is my syntax wrong? I'm not sure what would be throwing this error.

View 3 Replies View Related

C :: Assign Pointer Of A String To Integer

Mar 22, 2014

I have this code:

Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
[code]....

What I want is basically to assign to the *p the pointer of the string so that i could do the following printf(" print string %s",*p); so i dont know how to do that.

View 6 Replies View Related

C :: Incompatible Integer To Pointer Conversation

Nov 28, 2013

I am getting error"incompatible integer to pointer conversation..." and don't know how to fix this. In my code, user inters line like this (3+3*(55-52)) I need to separate number from the line so I can do other operation.here is my code

Code:

#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int main(){

[Code]....

View 1 Replies View Related

C :: Typecast - Integer To Structure Pointer

Aug 5, 2014

I have written this program

Code:
#include <stdio.h>
#include <string.h>
int main(void) {
struct point {

[Code] ....

error: request for member is not a structure or union
printf("%d
,%d
",p1->i,p1->j);

I was just trying to typecast a integer pointer to structure pointer, but throws error as shown.

View 5 Replies View Related

C++ :: ISO Forbids Comparison Between Pointer And Integer

Apr 21, 2013

I am trying to make a program that prints out an 8 by 8 board with 1 queen on each row.

For example, if the user enters: 0,3,4,0,0,7,6,7

the program should create following board and print:

Q.......
...Q....
....Q...
Q.......
Q.......
.......Q
......Q.
.......Q

I think I am doing it right but im getting a couple of errors that i cant fix ...

#include <iostream>
using namespace std;
int main(){
int x [8] [8], r, c;
for(c = 0; c <= 8; c++){
cout << " Enter a number from 1 to 7 " << endl;

[Code] .....

these are the errors :

assignment15_meem.cpp: In function âint main()â:
assignment15_meem.cpp:7: error: no match for âoperator>>â in âstd::cin >> x[c]â
assignment15_meem.cpp:10: error: ISO C++ forbids comparison between pointer and integer

View 7 Replies View Related

C/C++ :: ISO Forbids Comparison Between Pointer And Integer

May 4, 2014

template <class ST>
bool OrderedSet<ST>::IsIn (const ST & value) const {
for (LNode * np = first; np != NULL; np = np -> next)
if (np -> next == value)
return true;
return false;
}

View 1 Replies View Related

C++ :: Pointer - Allocate Integer Variable To T

Mar 29, 2012

In the code below:

void test(int * i) {
i = new int;
*i = 10;
cout << "i: " << *i << endl;

[Code] ....

The outuput is:

i: 10
t: (some memory position).

If I really want to allocate an integer variable to t, i need to modify the void test(int * i) procedure to void test(int *& i).

View 2 Replies View Related







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