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

Operations between types "struct _object*" and "int" is not allowed

The part of the code that is causing this error is:
Expand|Select|Wrap|Line Numbers
  1. newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self)); 
  2.  
I have tried to undefined the variable and malloc. I am not sure how to correct the error.
Also I am compiling this to with the ILE C AS400 compiler
The following is the entire code.....

Expand|Select|Wrap|Line Numbers
  1. /* NOTE: this API is -ONLY- for use with single byte character strings. */
  2. /* Do not use it with Unicode. */
  3.  
  4. #include "bytes_methods.h"
  5. #include "structmember.h"
  6. #include "stdlib.h"
  7. #include "Python.h"
  8. #include "stdio.h"
  9. #include "string.h"
  10.  
  11.  
  12. static PyObject*
  13. stringlib_isspace(PyObject *self)
  14. {
  15. const char* sum = (const char*)malloc(STRINGLIB_STR(self));
  16.     return _Py_bytes_isspace(sum, STRINGLIB_LEN(self));
  17. }
  18.  
  19. static PyObject*
  20. stringlib_isalpha(PyObject *self)
  21. {
  22. const char* sum = (const char*)malloc(STRINGLIB_STR(self));
  23.     return _Py_bytes_isalpha(sum, STRINGLIB_LEN(self));
  24. }
  25.  
  26. static PyObject*
  27. stringlib_isalnum(PyObject *self)
  28. {
  29. const char* sum = (const char*)malloc(STRINGLIB_STR(self));
  30.     return _Py_bytes_isalnum(sum, STRINGLIB_LEN(self));
  31. }
  32.  
  33. static PyObject*
  34. stringlib_isdigit(PyObject *self)
  35. {
  36. const char* sum = (const char*)malloc(STRINGLIB_STR(self));
  37.     return _Py_bytes_isdigit(sum, STRINGLIB_LEN(self));
  38. }
  39.  
  40. static PyObject*
  41. stringlib_islower(PyObject *self)
  42. {
  43. const char* sum = (const char*)malloc(STRINGLIB_STR(self));
  44.     return _Py_bytes_islower(sum, STRINGLIB_LEN(self));
  45. }
  46.  
  47. static PyObject*
  48. stringlib_isupper(PyObject *self)
  49. {
  50. const char* sum = (const char*)malloc(STRINGLIB_STR(self));
  51.     return _Py_bytes_isupper(sum, STRINGLIB_LEN(self));
  52. }
  53.  
  54. static PyObject*
  55. stringlib_istitle(PyObject *self)
  56. {
  57. const char* sum = (const char*)malloc(STRINGLIB_STR(self));
  58.     return _Py_bytes_istitle(sum, STRINGLIB_LEN(self));
  59. }
  60.  
  61.  
  62. /* functions that return a new object partially translated by ctype funcs: */
  63.  
  64. static PyObject*
  65. stringlib_lower(PyObject *self)
  66. {
  67. char* sum1;
  68. const char* sum = (const char*)malloc(STRINGLIB_STR(self));
  69.     PyObject* newobj;
  70.     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
  71.     sum1 = (char*)malloc(STRINGLIB_STR(newobj));
  72.     if (!newobj)
  73.             return NULL;
  74.     _Py_bytes_lower(sum1, sum,
  75.                  STRINGLIB_LEN(self));
  76.     return newobj;
  77. }
  78.  
  79. static PyObject*
  80. stringlib_upper(PyObject *self)
  81. {
  82. char* sum1;
  83. const char* sum = (const char*)malloc(STRINGLIB_STR(self));
  84.     PyObject* newobj;
  85.     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
  86.     sum1 = (char*)malloc(STRINGLIB_STR(newobj));
  87.     if (!newobj)
  88.             return NULL;
  89.     _Py_bytes_upper(sum1, sum,
  90.                  STRINGLIB_LEN(self));
  91.     return newobj;
  92. }
  93.  
  94. static PyObject*
  95. stringlib_title(PyObject *self)
  96. {
  97. char* sum1;
  98. char* sum = (char*)malloc(STRINGLIB_STR(self));
  99.     PyObject* newobj;
  100.     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
  101.     sum1 = (char*)realloc(sum,STRINGLIB_STR(newobj));
  102.     if (!newobj)
  103.             return NULL;
  104.     _Py_bytes_title(sum1,sum,
  105.                  STRINGLIB_LEN(self));
  106.     return newobj;
  107. }
  108.  
  109. static PyObject*
  110. stringlib_capitalize(PyObject *self)
  111. {
  112. char* sum1;
  113. char* sum = (char*)malloc(STRINGLIB_STR(self));
  114.     PyObject* newobj;
  115.     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
  116.     if (!newobj)
  117.             return NULL;
  118.     sum1 = (char*)realloc(sum,STRINGLIB_STR(newobj));
  119.     _Py_bytes_capitalize(sum1, sum,
  120.                       STRINGLIB_LEN(self));
  121.     return newobj;
  122. }
  123.  
  124. static PyObject*
  125. stringlib_swapcase(PyObject *self)
  126. {
  127. char* sum1;
  128. char* sum = (char *)malloc(STRINGLIB_STR(self));
  129.     PyObject* newobj;
  130.     newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));
  131.     sum1 = (char*)realloc(sum,STRINGLIB_STR(newobj));
  132.     if (!newobj)
  133.             return NULL;
  134.     free (sum);
  135.     _Py_bytes_swapcase(sum1,sum,
  136.                     STRINGLIB_LEN(self));
  137.     return newobj;
  138. }     
  139.  
May 6 '15 #1
1 3109
update: I found the solution........ inside ctype.h file I defined the struct as an int "#define objectint(b) *(uint8_t*)&b" and then I went to the offending line of code and change "newobj = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));" to "objectint(newobj) = STRINGLIB_NEW(NULL, STRINGLIB_LEN(self));"
May 6 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

24
by: Matt Feinstein | last post by:
Hi all-- I'm new to Python, and was somewhat taken aback to discover that the core language lacks some basic numerical types (e.g., single-precision float, short integers). I realize that there...
9
by: Gonçalo Rodrigues | last post by:
Hi all, I have a few questions on primitive types that I will divide in two main questions. I realize that some of these questions -- especially 2. below -- are not directly related to C++ as a...
32
by: aruna | last post by:
Why division/mulitiplication/addition of pointers are not allowed in C?
20
by: GS | last post by:
The stdint.h header definition mentions five integer categories, 1) exact width, eg., int32_t 2) at least as wide as, eg., int_least32_t 3) as fast as possible but at least as wide as, eg.,...
2
by: Herby | last post by:
I need to define my own types and arrays of these types. These types are for the most part extensions of the built in types and need to provide all the basic operations of arithmetic and...
6
by: miked | last post by:
Why are there still no covariant return types? All searches reveal no workarounds accept for using an interface which is a real pain. I wind up missing this capability almost every time I...
6
by: carsonbj | last post by:
I have an issue where the below operation works on a little-endian architecture but not on a big-endian architecture. I was under the impression that pointer arithmetic is architecture independant...
58
by: jacob navia | last post by:
Hi people I have been working again in my tutorial, and I have finished the "types" chapter. If you feel like "jacob bashing" this is the occasion! I am asking for criticisms, or for things I may...
13
by: jehugaleahsa | last post by:
Hello: Today I learned that the + operator cannot be passed a delegate. I get an error from the CLR saying I have an invalid program. With that, I was wondering if someone could tell me what...
1
nbiswas
by: nbiswas | last post by:
Welcome to the lesson on R data structures. To perform any meaningful data analysis we need to collect our data into R data structures. In this lesson we will explore the most frequently used...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.