Questions tagged [declaration]
Declaration is the part of the subprogram (procedure or function) which provides the protocol(header), but not the body of the subprogram.
3,390
questions
0
votes
1
answer
22
views
Override/Extend Type Declaration Properties
I installed an awesome npm package with its type declaration. But I noticed some mixups & missing pieces in its properties & type declarations.
I need to override or extend those properties to ...
2
votes
6
answers
94
views
How would I declare an array of function pointers in C?
How would I declare a as a array of 4 pointers to functions with no parameters and which return void? The pointers originally point to functions with names: insert, search, update, and print.
This is ...
0
votes
3
answers
38
views
C# object list that can be declared, returning an iteration of items to be inserted into the main list
C# question.
I need to fill my main object property, that is a list of a custom object, but at some point, I need to add to this list a replication with a specific declaration, but I don't want to ...
-1
votes
2
answers
79
views
Understanding an embedded C language variable declaration
I'm trying to understand some embedded C code that declares a variable.
uint8_t *p=(uint8_t *)&NOCAN_REGS;
The NOCAN_REGS is a structure defined in a different file (see link below)
My ...
0
votes
2
answers
67
views
Declaring array of values to a struct or a pointer
I have what appears to be an infuriatingly simple problem. I have calculated a window function (a long 1-D array of numbers) using Matlab and would like to declare this to a variable array via a ...
6
votes
3
answers
250
views
C23 auto vs C++11 auto
The C23 standard apparently has introduced using "auto" keyword for auto type deduction, see here, just like in C++11. However, there seems to be some differences.
According to here, https://...
0
votes
0
answers
26
views
Why variable to constant cannot be used in declaration of static array in C? [duplicate]
const int size = 20;
char str[size];
Why this statement is illegal in C while this would be same as:
char str[20];
At least in my understanding the first declaration could be legal. I may be ...
1
vote
1
answer
38
views
C++ undefined class declarations which I have already included
My problem is about including header files. I don't want to include headers in other header file so when I need it, I always write declarations the beginning of the header and include in the cpp files ...
3
votes
1
answer
86
views
Is there a way to prevent calling the constructor without assigning it to a variable?
i.e. this should be ok:
Object obj("param");
but this should not:
Object("param");
Is there a way to prevent the second scenario from being done?
0
votes
0
answers
12
views
Incorrect data security form - SPLIT_BUNDLE 5
i just finished my project (business manager) and I'm facing problem with policy declaration and google reject my app.
How to fullfil data security form? , could you help me please?
-First of all, a ...
0
votes
2
answers
68
views
How to deconstruct complex C/C++ statements/declarations?
Take the following snippet as an example.
char* const (*(* const bar)[5])(int)
Cannot seem to make sense of it or more so, cannot identify the initial point from where to begin making sense of it.
-2
votes
0
answers
20
views
'input' is not a valid type keyword in variable declaration
i keep getting Error at 18:0 'input' is not a valid type keyword in variable declaration not sure why it is sayng that i have tried this updated script, the length and mult variables are declared as ...
0
votes
2
answers
80
views
Problem with custom written compare function
could someone have a quick look at my code because i just can't find out why i am not getting the result i want. The goal here is to find largest and the smallest number from an array that i gave to ...
1
vote
3
answers
45
views
Declare local variables oracle toad
How can I write a basic query, which declare variables and print those variables in a select statement.
I tried assign values to variables and it ran successfully. But when I print it, that didn’t ...
0
votes
0
answers
13
views
Can Windows codeless drivers be shared across architectures x86_64 and ARM64 or do they need to be separate
We have simple Windows codeless drivers with just some INF declarations. Can one be shared across architectures x86_64 and ARM64 or do they need to be in separate .cat instances?
The inf2cat /os: ...
0
votes
3
answers
51
views
invalid operands to binary expression ('char ()' and 'int')
`I've been trying this code to show if a number that I type is even or odd, but it gets an error when I run it:
ERROR:`
make -s
./main.c:8:13: error: invalid operands to binary expression ('char ()' ...
0
votes
3
answers
68
views
What is the difference between a struct in a struct, and a named anonymous struct that is part of a surrounding struct?
Example:
#include <stdio.h>
struct not_inner {
int a;
int b;
};
struct outer {
struct {
int a;
int b;
} x;
struct not_inner y;
};
int main()
{
...
0
votes
0
answers
9
views
need example of the interdependencies among the declarations and definitions of friend classes/ friend member functions (from C++ Primer)
I'm new to C++ and currently reading C++ Primer and in Chapter7( which talks about the most basic class features) it talks about how important "careful structuring" is when we want to make ...
0
votes
2
answers
34
views
Warning: implicit declaration of function 'showMenu' [-Wimplicit-function-declaration] [duplicate]
I get this weird warning message in Visual Studio Code the whole time and have no idea what else I should change.
Message:
warning: implicit declaration of function 'showMenu' [-Wimplicit-function-...
2
votes
2
answers
91
views
Is it valid to declare a static array with no length, and then define it with a length?
Consider this code:
class Foo {
private:
static char buffer[];
};
char Foo::buffer[100];
Is this valid, or do I need to put buffer[100] also in the class definition?
0
votes
3
answers
55
views
stack operation using c language [closed]
can anyone help me why this code is not working?
this code is not showing any output nor any error.
#include <stdio.h>
#include <stdlib.h>
struct stack {
int size;
int top;
...
0
votes
2
answers
60
views
Displaying an element of a linked list
i would like to ask something again about why i am not getting my elements displayed by trying it to put out through a linked list.
I was following one tutorial for this matter but although it seems ...
0
votes
1
answer
36
views
typescript: how to declare types in another javascript module
suppose that I have a JavaScript library that export some types for uses(says js1.js). and I have some typescript codes that sits in a "<"script type="module">" tag that ...
0
votes
2
answers
56
views
a parenthesis expression assigned to single lvalue [duplicate]
Why does this code compile ?
int X = (2,4);
I compiled this line with c++ replit
the second value (4) is assigned to X
2
votes
1
answer
77
views
How does a pointer typedef struct work in C?
I have learned that typedef allows me to give a struct a name that can be referenced without needing to specify struct before the name. For example, I can create an instance of Network 2 different ...
-1
votes
1
answer
38
views
Data definition has no type or storage class [type defaults in declaration]
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <curses.h>
#define EMPTY ' '
#define BORDER '*'
#define PLAYER 'P'
#define GOAL 'G'
#define COLLAPSED 'X'
...
3
votes
2
answers
78
views
Pointer to incomplete class type "struct punto" is not allowed
I'm trying to create a code that creates a list of points. I have a file named "punti.c" with its header and a file named "item.c" with its header. The problem is that I can't ...
2
votes
1
answer
63
views
I want to the same string multiple times in C via printf
I'm doing Harvard CS50, and in the second class on C, the instructor says %s would automatically print each extra argument in succession.
Okay, that's cool. But what if I want to print the first ...
4
votes
1
answer
215
views
Why do compilers allow a data member have the same name as the class?
Three major compilers (gcc, clang, MSVC) happily compile the following example (godbolt):
struct Test
{
// Member type `Test::Test` is supposedly introduced at this point
// as an alias to `...
1
vote
2
answers
67
views
Why is pointer decay okay but externally linking an array as a pointer not okay? [duplicate]
Given that C insists on decaying array types into pointers, when passing arrays to functions, then why is it UB to externally link to an array as a pointer?
As an example:
MyFile.c
// Declare and ...
0
votes
1
answer
54
views
I am having trouble with declaration files in TypeScript
I'm trying to use the trace function in my TypeScript code, which has been declared in a .d.ts file as follows:
declare function trace(arg: string | number | boolean);
declare function trace(arg: { id:...
2
votes
2
answers
43
views
Asking user to input the sizes of 2D array C program
I'm coding a C program that asks the user to input two variables that represent the 2d array sizes and then print the array, I don't know where the problem is! any help?
`#include <stdio.h>
int ...
0
votes
3
answers
134
views
in C, why do variables need to be declared before use but functions dont?
I'm reading K&R and started wondering, why do variables need to be declared before they are used,
but functions dont?
In C, all variables must be declared before they are used, usually at the ...
1
vote
1
answer
53
views
Why a function parameter(Myclass) can have L and R values but same return type (Myclass) can only returns R value?
I am having a hard time understanding of this concept.
I can send L value and R value as a parameter in
Myclass foo(Myclass)
but can not return L and R value from that function. Only R values comes ...
1
vote
4
answers
88
views
Is array declaration notation a shorthand for malloc in C?
From this tutorial website:
To declare an array in C, a programmer specifies the type of the
elements and the number of elements required by an array as follows −
type arrayName [ arraySize ];
It ...
0
votes
0
answers
22
views
While loop split into multiple files . n output when printing
its a simple while loop i' trying to split into multiple files in Xcode . code shows no error but i can not print
output . here is the code :
its a simple while loop i' trying to split into multiple ...
0
votes
0
answers
18
views
Undefined reference to function linker error [duplicate]
I'm aware this is an often asked question, but none of the solutions in SO solves my problem.
I'm currently making a thread pool implementation with definitions and declarations in different files to ...
-1
votes
2
answers
87
views
c++ how to count arrays within an array
suppose I have this code :
int arr[] = {{1, 4}, {2}, {3, 2, 6}};
how do I count the number of arrays within an array, which in this case would be 3.
if the code dosen't work is there a way to get the ...
1
vote
1
answer
68
views
How to declare an external structure in C
I have already implement an external int in my .h file, with
extern int GLOBAL_RETURNVAL;.
I would like to know how to declare an external structure in the same way (to contain both this int and also ...
0
votes
1
answer
93
views
Translate a C# DLL external function declaration to Delphi
I have to translate this C# external function DLL declaration to Delphi:
[DllImport("CRT_571.dll")]
public static extern int ExecuteCommand(UInt32 ComHandle, byte TxAddr, byte TxCmCode, byte ...
0
votes
0
answers
31
views
Function declaration under the hood
const var1 = 8;
const var2 = 9;
function func1(){
console.log("Inside func1")
}
func1();
When above programme will be executed a global execution will be created Inside Global ...
2
votes
4
answers
291
views
How to initialize C structs with default values
I have this defined struct:
#include <stdio.h>
#include <stdlib.h>
typedef struct Node {
int data;
struct Node* prev;
struct Node* next;
} Node;
typedef struct List {
int ...
0
votes
1
answer
59
views
How to befriend method from other class that handles this class (incomplete types problem)? [duplicate]
This sounds like a very obvious question but I can't find anything on the internet. I have a class other that handles a message in one of its methods. To do so, it has to access a private data member ...
2
votes
2
answers
57
views
Is there a way to hide the private members of a class, to the clients of that class?
The users of a class need not see the private members of that class. Those members may introduce new types the users should not be aware of, requiring #include of files to declare those types. I would ...
1
vote
3
answers
94
views
Struct declaration NOT sufficient?
Having the following C code:
struct Point2_s;
struct Point1_s{
int x;
int y;
Point2_s P2;
} Point1;
struct Point2_s{
int x;
int y;
} ;
int main() {
...
return 0;
}
I'm getting an ...
0
votes
0
answers
27
views
How to properly declare functions in C++? [duplicate]
I found a couple of examples onlines but I can't figure out how to properly declare functions in my .cpp vs my header file. Can you help me figure out where I'm going wrong? Here is my code:
...
3
votes
2
answers
143
views
Is `inline;` an invalid declaration or not a declaration at all?
Say I want to know what is a declaration. I go to [dcl.pre] and read that
Declarations have the form
followed by various possible forms, one of which is a simple-declaration, which can, in turn, ...
0
votes
0
answers
19
views
Typescript - Extending existing module declarations and publish them
I am making a module that extends the uses of a package,
Then I have added the new types with example:
declare module "meteor/meteor" {
module Meteor {
interface User {
field1: ...
0
votes
0
answers
25
views
How to fix Declaration .... must be compatible with .... while changing PHP7.4 to PHP8
while changing PHP7.4 to PHP8 i get the following error message of my PHP script:
Exception: Declaration of jtl\Connector\Modified\Mapper\StatusChange::push(jtl\Connector\Model\StatusChange $status) ...
1
vote
3
answers
65
views
A code for accessing each element of the structure array variable via pointer
In the following line :
struct student *ptr = NULL;
Why is ptr set to NULL?? can someone plss tell me..
#include <stdio.h>
int main(void) {
// student structure
struct student {
...