Questions tagged [c99]

0

votes
0

answer
20

Views

time in milliseconds in c99?

I'm trying to figure out how to calculate the milliseconds between some socket programming connections in C99 but getting 0 ms on the C99 and returns an actual value on the mac terminal. I included time parts of my code. Init: struct timeval start,end; double t1,t2; t1 = 0.0; t2 = 0.0; start of ope...
STOPIMACODER
1

votes
0

answer
65

Views

Needs some light on c99 Bit Field explanation

I am reading gnu c99 manual and it has mentioned: Bit fields can be specified without a name in order to control which actual bits within the containing unit are used. However, the effect of this is not very portable and it is rarely useful. You can also specify a bit field of size 0, which indicate...
Monk
1

votes
0

answer
108

Views

C99 floating point intermediate results

As per the C99 standard: 6.3.1.8.2: The values of floating operands and of the results of floating expressions may be represented in greater precision and range than that required by the type; the types are not changed thereby.52)> However, outside the scope of Annex F, we have: 5.2.4.2.2.7: The va...
Kay
1

votes
3

answer
55

Views

create an array whose length is determined by user input: C vs C99 vs Java

I am trying to figure out methods to create an array whose length is determined at run time (e.g., by user input) in C and Java. In C, I know that some versions of C standards such as C99 now allow the following way: int size; scanf('%d',&size); int arr[size]; However, theoretically, it is not accep...
1

votes
2

answer
79

Views

Reordering of access to multiple volatile variables in C

In this example: volatile uint32_t * pOne = 0xDEADBEEF; volatile uint32_t * pTwo = 0x0BADC0DE; void same(void) { uint32_t tmp; tmp = *pOne; // A *pOne = 0; // B *pOne = tmp; // C } void different(void) { uint32_t tmp; tmp = *pOne; *pOne = 0; // E *pTwo = 0; // F *pOne = tmp; } As far...
HeLLoTIS
1

votes
1

answer
62

Views

How to Floodfill a bitmap using Android Renderscript?

I am trying to floodfill a bitmap using Renderscript. and my renderscript file progress.rs is #pragma version(1) #pragma rs java_package_name(com.intel.sample.androidbasicrs) rs_allocation input; int width; int height; int xTouchApply; int yTouchApply; static int same(uchar4 pixel, uchar4 in); uchar...
Jitendra Singh
-1

votes
0

answer
19

Views

Allowing the user to edit text already printed on the screen in C

I want to change the text on my screen like a word processor by user input, so can i do gets('text the user can edit', variable to edit by text) I have tried arrays, and have tried researching dynamically created variables for this. My code is below: #include int main(void) { int run; int run = 1;...
repl user
1

votes
3

answer
59

Views

How to link multiple .c files

I know that you have to create a header file and #include it in your main. I have done that and when I compile my code for some reason it is unable to figure out where one of my functions are. The layout of my project is a: threads.c makeCityFromInput.h and makeCityFromInput.c I have the threads.c #...
Jack Hyland
1

votes
1

answer
43

Views

Logical OR not operating as expected

I'm writing a helper function to check if the path entered by the user contains 2 chars less than the buffer over flow. I'm using fgets() for input so I know two things. The very last index will contain a '\0' char (Null terminating char) If the user enters more chars than my limit, a char that is...
StreetSweepingJoe
1

votes
0

answer
30

Views

R configure error that C99 double complex is required

I am trying to update R to version 3.5.3 on my Centos 7 server with a GCC compiler of version 8.2.0. But when I tried to configure in the home directory of R-3.5.3, it was stuck with the following error: checking complex.h usability... no checking complex.h presence... no checking for complex.h... n...
Utaha Tahimi
1

votes
2

answer
152

Views

Dealing with ctype.h integer overflow

What is the proper way to deal with character values which when casted to an unsigned char fall between {INT_MAX + 1 ... UCHAR_MAX} where UCHAR_MAX is greater than INT_MAX. int is_digit(char c) { unsigned char uchar = c; if(uchar > INT_MAX) return MAYBE; return isdigit((int)uchar) ? YES : NO; }
Elite Mx
1

votes
2

answer
226

Views

operator keyword in Xcode

I'm facing a problem in Xcode with the operator keyword. I have this in a header file (.h) but Xcode recognizes it as a keyword due to operator overloding in C++, even though I'm setting the file type as a default C header and not C++ header. The code I'm trying to compile is all written in C and...
Raphael Ayres
1

votes
3

answer
112

Views

migrate code using C99 dynamically allocated multidimensional arrays into C++

I'm in the process of trying to learn how to do things in C++, and one of the aspects with which I'm grappling is how to efficiently implement dynamically allocated multidimensional arrays. For example, say I have an existing function: void myfunc(int *lambda, int *D, int *tau, int r[*tau][*D]) { i...
B. Tyner
1

votes
1

answer
274

Views

Is PellesC strictly-conforming to standard C99?

I have found in http://en.wikipedia.org/wiki/C99 that Pelles C has full support for C99. However I have doubts. As probably you know, the GCC project has not yet reached full support for C99. The details in which GCC is conforming or not are very well documented. However, I cannot understand what...
pablo1977
1

votes
1

answer
907

Views

Checking if an argument is passed in variadic macros in C

For cleaner error handling I use a macro (it uses C99 and GCC extensions); the behavior is like standard assert: #define A(cond, msg, ...) ({ \ if (!(cond)) { \ if (msg) \ say(msg, ##__VA_ARGS__); \ else \ say('Error at file %s, function %s, line %u: %s', \ __FILE__, __func__, __LINE__, #cond); \ A_...
1

votes
2

answer
86

Views

How to write a foreach-like macro to visit all nodes of a graph

Suppose I have a graph of the following nodes: typedef struct node node_t; struct node { size_t adjacent_node_count; node_t **adjacent_nodes; void* data; }; The graph is represented as a pointer to one of these nodes (that is, I dont have a single list of all nodes, but every node is guaranteed to b...
yuri kilochek
1

votes
1

answer
268

Views

GCC 4.8.1 compile time in C99 code with many macros and inline functions

I try to compile a code with many lines of Algebra in it. Basically, it is a brute force contraction of 2 tensors with 12 dimensions and variable mode size. However, the performance of the code is not an issue at the moment, since it does not even compile. The code itself is embedded in a larger fra...
tkurth
1

votes
1

answer
99

Views

Strange output of char array converted to int - magic of array[x] - '0'

So I'm fooling around with char arrays conversion and testing now this simple code: #include int main(void) { char arr[BUFSIZ]; printf('Input: '); fgets(arr, sizeof(arr), stdin); int x = arr[0] - '0'; printf('Output: %d\n', x); } The output should be value of variable x which is first digit of inpu...
spaffy
1

votes
1

answer
46

Views

C99: Return a value after it's been free'd from the heap

I'm wondering if there's a way to return a value just before it's free'd from the heap. My problem is that if I do something like this: queue_item *dequeue(queue *this) { node old = this->front; this->front = old->link; free(old->item); free(old); return(old->item); } Clearly old->item is taken off...
user3674626
1

votes
1

answer
88

Views

Clarification needed on (u/i)int_fastN_t

i read many explanation on fastest minimum-width integer types but i couldn't understand when to use these data types. My understanding : On 32-bit machine, uint_least16_t could be typedef to an unsigned short. 1. uint_least16_t small = 38; 2. unsigned short will be of 16 bits so the value 38 will b...
Harsha
1

votes
1

answer
228

Views

Mips translation from C recursion wrong output

The problem is called the Eight Queens problem (placing 8 queens on an 8 x 8 chessboard such that none of them can attack/threaten each other). I have the following solution in C and it uses recursion to print all possible solutions. I want to make it non-recursive but I had trouble with that so I j...
Brandon
1

votes
1

answer
124

Views

Multiple c language dialects

I'm trying to integrate a series of code files (Cocos3d files) which by default are gnu-c99, into my project that is to be c11 on account of other libraries its using. I started manually editing the cocos3d files (mostly it was just struct references that were throwing compiler errors) to compile; b...
Reece
1

votes
2

answer
620

Views

Preprocessor macros: any way to get a unique variable name and reuse it?

I am trying to use unique variable names every time my macro is expanded, I cannot come up with a solution I have code something like this #define _each(results,arr,i,v, f)\ for (i=0;i
boredguy
1

votes
1

answer
283

Views

How to use abs and div with fixed-size integers

In C99 we have fixed-size integer types, defined in stdint.h. In stdlib.h we have the abs and div functions which operate on ints, as well as their long int/long long int counterparts labs, llabs, ldiv, lldiv. Since the size of int/long/long long varies based on platform and used compiler I wonder...
Askaga
1

votes
1

answer
74

Views

How to specify the memory location (fast/slow) of functions/vars in C99?

On many embedded architectures, it is possible to run the code or store data either into the internal RAM (fast access) or the external SDRAM (slow access). On architectures like SHARC processors it is possible to define the memory region where a function will be linked to. segment('seg_ext_dm32')...
nowox
1

votes
1

answer
56

Views

Unexplainable behaviour of c array in OpenCL

I ran across an interesting problem: If I define an array inside my function, it works fine, however if I define the same array outside the function and pass it as a parameter, the array behaves differently. void main() { unsigned short arr[8] = {0,1,2,3,4,5,6,7}; fun([...], arr); } void fun([...],...
Addi
1

votes
2

answer
158

Views

Is a C99 complex type binary compatible with a structure with two members?

Can I use typedef struct {double r; double i;} DC; as a binary compatible data type for C99 double complex type? My experimental C code works in my case (gcc / x86-64 / Linux). But is this universally valid? /* gcc -o test test.c (WORKS) */ /* gcc -O3 -march=native -o test test.c (WORKS with volatil...
Jan Šmydke
1

votes
1

answer
45

Views

C adding struct which has been initialized by a function overrides original

Node.h typedef struct Node Node; struct Node{ int rank; int marked; size_t nSize; size_t nCapacity; char * name; Node * predecessor; Table * weights; void (*print)(Node * toPrint); ///< print function for printing all info Node ** neighbors...
Mike Rinos
1

votes
1

answer
225

Views

C99 standard and gnu libc printf

the c99 standard (ISO/IEC 9899:1999) says that the length field of pintf format placeholder can be L, that apply only to float number. Thi is confirmed also in printf(3) manpage: L A following a, A, e, E, f, F, g, or G conversion corresponds to a long double argument. If I compile this: printf('%Ld'...
mastupristi
1

votes
1

answer
29

Views

simultaneous struct member initialization and definition in c99

I'm trying to create a trie, and I need to have all the booleans equate to false unless otherwise specified. However, this format for simultaneous member initialization and definition is only valid in c++11 apparently... Is there any way to do this in c99? typedef struct { bool booleans[28] = { fals...
redraze
1

votes
2

answer
46

Views

Access 2D arrays through their pointer

I'm having some problems trying to access a true 2D array in my program. I have a 1D array that emulates a 2D array to hold some level information (tile based game). When I access to some tile I do the common operations to change row/column index to liniar array: The map is allocated in heap, and I...
Bungow
1

votes
1

answer
1.5k

Views

Implicit declaration of function 'sqlite3_rekey' is invalid in C99

when i update Xcode from 8.3.3 to Xcode 9GM ,i used pod 'FMDB/SQLCipher' before and it was OK. now it says 'Implicit declaration of function 'sqlite3_rekey' is invalid in C99' i try to solve this but it dose not work , how can i do ?
leeSin
1

votes
1

answer
288

Views

extern declaration of array

I have an array with size determined during compile-time defined in a source file. const int array[] = {1, 3, 3, 7}; The number of the elements could change in the future so I'd rather not hardcode it in the brackets. This array needs to be accessed from several source files so I'm trying to add an...
martinkunev
1

votes
3

answer
77

Views

standard way to solve “passing argument of function from incompatible pointer type” with function pointers parameter

I have a list module implementing a foward list, like the following (minimal working example): #include #include #include #include struct list_cell { void* payload; struct list_cell* next; }; struct list { struct list_cell* head; int length; }; typedef bool(*matcher_t)(const void* data); void* f...
Koldar
1

votes
2

answer
124

Views

Are conformant array parameters VLAs?

CERT's Secure Coding Standard includes an item (API05-C) which encourages the use of conformant array parameters, which is a recommendation I've implemented in a lot of my code (hidden behind a macro for compilers which don't support them). For those who don't know, a conformant array parameter is s...
nemequ
1

votes
1

answer
80

Views

language standard version versus compiler version

What is the difference between the C version (e.g. C99) and the C compiler version (e.g. 4.9.3) $ ./arm-none-eabi-gcc --version arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.9.3 20150529 (release) [ARM/embedded-4_9-branch revision 227977 with DYNAMIC_REENT by Ambarella] Copyright (C) 2...
tarabyte
1

votes
1

answer
55

Views

TCP Client - Receive message from unknown / unlimited size

I am currently sitting at a university task and am facing a problem that cannot be solved for me. I'm developing a TCP client which connects to a server and gets a message from there. The client should be able to work with strings of any length and output all received characters until the server cl...
wit4r7
1

votes
1

answer
0

Views

MS VS 2008 and C99

I read with interest the post 'How universally is C99 supported ?'. One of the comments therein points that Microsoft doesn't support C99. But the comment symbol // works with VS 2008 and this symbol is in C99. I have two questions: To what extent VS 2008 support C99? Is it ok in the same code to mi...
yCalleecharan
1

votes
2

answer
0

Views

Device descriptor in lufa… What kind of structure is this (inside)? I think it is nothing specific, and only a question to C/C++ programmers

I am using LUFA for a project and after reading some of the examples I saw some of these constructs. Are these macros? I know AVR devices and know that PROGMEM is one? But what is .Header and why is it starting with a '.'. Can someone explain to me how to create contructs like these or show me where...
try
1

votes
7

answer
0

Views

Copying and freeing malloc'ed pointer

I'm trying to hunt down memory leaks and have found one source. I am malloc'in the pointer in one function and freeing it in another, but I'm missing out on understanding how to copy the value the pointer points to while also being able to free the pointer. Current implementation (with memory leak):...
Rio

View additional questions