标签: inline

CSS 中的 SVG DataURI 在 Firefox 中不起作用

body {
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='30.000000pt' height='30.000000pt' viewBox='0 0 300.000000 300.000000' preserveAspectRatio='xMidYMid meet'><g transform='translate(0.000000,300.000000) scale(0.100000,-0.100000)' fill='#3F0607' stroke='none'><path class='node' id='node1' d='M1255 2979 c-214 -37 -373 -98 -560 -212 -105 -64 -246 -187 -333 -291 -457 -540 -483 -1307 -65 -1871 453 -611 1297 -784 1958 -402 156 91 335 250 448 399 31 42 57 80 57 84 0 4 6 15 14 23 30 34 105 191 140 293 124 359 113 724 -31 1078 -155 380 -487 695 -874 …
Run Code Online (Sandbox Code Playgroud)

css svg inline

2
推荐指数
1
解决办法
907
查看次数

extern 内联函数被引用但未定义

void foo(void) {}我有一个我希望内联的函数(让我们称之为它)。但是我在 .cpp 文件中定义了它。
我无法将该函数移动到标头,因为它正在使用 .cpp 中的其他函数。



编辑:
下面的代码就像真实的代码一样不使用 C++ 功能。我可以明确补充:

#ifdef __cplusplus
extern "C"
#endif
Run Code Online (Sandbox Code Playgroud)

如果我想将下面的代码转换为 c99,我只需要更改我的项目属性(或 makefile,如果您愿意)而不是代码。我也在询问c++,因为它可以解决我的问题,而c99不能。
因此我的问题中的 C 和 C++ 标签是合理的。代码是可移植的,
请参阅:When to use extern "C" in C++?



编辑#2
好吧,我明白我必须将foo()定义放在头文件中。如何在不将它们移动到头文件的情况下调用func_a()和func_b()from ?foo()有什么解决方法吗?



示例
文件.c/.cpp:

int    func_a (int a,    int b,    int c)    {/*...*/};
double func_b (double a, double b, double c) {/*...*/};

void   foo    (int a, double b) { // unction definition
    //...
    int myInt …
Run Code Online (Sandbox Code Playgroud)

c c++ inline extern

2
推荐指数
1
解决办法
5931
查看次数

错误 C1189 #error:C++ 标准库禁止宏化关键字“inline”

我正在将一个项目从 VS 2010 迁移到 VS2019。我的代码在 VS 2010 中运行良好,而在 VS2019 中对于相同的代码却出现错误。

#undef inline
#define inline __forceinline

..///
..///code 

#undef inline
#define inline inline
Run Code Online (Sandbox Code Playgroud)

Error C1189 #error: The C++ Standard Library forbids macroizing the keyword "inline". Enable warning C4005 to find the forbidden define

我怎样才能消除这个错误。

c++ migration inline visual-studio-2010 visual-studio-2019

2
推荐指数
1
解决办法
5325
查看次数

在 C 中调用其他较大函数的函数使用静态内联

假设我有一个函数,

static inline int res( int x )
{
  /** total() is a large func */
  int processedPkts = total();
  return ( processedPkts + x);
}

int total()
{
   /** Where the function total() does lot of processing,counting no of packets 
    or say, it has many lines of code */
}
Run Code Online (Sandbox Code Playgroud)

所以,我的问题是,我可以使用静态内联res()函数来调用更大的函数吗?

根据我对为什么/何时使用内联的理解,

它鼓励编译器将函数构建到使用它的代码中(通常是为了提高执行速度)。

静态内联通常与小函数一起使用,这些函数在调用例程中比使用调用机制更好地完成,仅仅是因为它们如此短且快,以至于实际执行它们比调用单独的副本更好。

因此,在汇编级别,total()函数不受静态内联影响(使用常规调用机制),因此建议对res()?使用静态内联。

c static gcc inline compiler-optimization

2
推荐指数
1
解决办法
396
查看次数

C:对内联函数的未定义引用

由于我的上一个问题因糟糕的代码风格和拼写错误而被关闭,我对其进行了审查并再次寻求帮助。

我正在尝试解析 PE 格式的 .exe 文件。这是我的代码的一部分

    #include "PE_resolve.h"
    #define SIZEOF_SECTION_HEADER 0x28

     /*load filebuffer into Imagebuffer*/
    int Read_2_ImageBuffer(void **p_filebuffer, void **p_Imagebuffer,long filesize);
    
    /*helper function*/
    inline void * Get_NT_POS(void **p_filebuffer);
    inline void * Get_FileHeader_POS(void **p_filebuffer);
    inline void * Get_Opt_FileHeader_POS(void **p_filebuffer);

    
    int main(){
        return 0;
    }

    int Read_2_ImageBuffer(void **p_filebuffer, void **p_Imagebuffer,long filesize){
       /*allocate memory for imagebuffer*/
       void *Opt_PE_Header = Get_Opt_FileHeader_POS(p_filebuffer); //THE ERROR LINE
       DWORD SizeOfImage = *(DWORD*) ((BYTE *)Opt_PE_Header + 0x38);
       *p_Imagebuffer = malloc(SizeOfImage);
        if(*p_Imagebuffer == NULL){
            printf("can't allocate enough heap memory\n");
            exit(EXIT_FAILURE); …
Run Code Online (Sandbox Code Playgroud)

c inline undefined-reference

2
推荐指数
1
解决办法
2498
查看次数

不同翻译单元中的内联静态变量具有不同的值(c++17)

我想实现一个包含全局变量的源文件,并且我想通过inline static. 我可以在翻译单元的上下文中更改变量(例如,i),但是当我在该翻译单元之外调用该变量时,调用者的结果将保持不变。就好像每个单元都有一个副本。请参阅下面的示例:

头文件.h

#ifndef UNTITLED1_TEST_H
#define UNTITLED1_TEST_H

namespace t {
    inline static int i{0};

    void inc() ;

    void print_i() ;
}

#endif //UNTITLED1_TEST_H
Run Code Online (Sandbox Code Playgroud)

头文件.cpp

#include "header.h"

void t::inc() {
    t::i++;
}

void t::print_i() {
    std::cout << t::i << std::endl;
}
Run Code Online (Sandbox Code Playgroud)

那么让我们看看程序如何执行:

主程序

#include "header.h"

int main() {
    t::inc();

    std::cout << t::i << std::endl; // -> output is: 0
    t::print_i(); // -> output is : 1
}
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,该变量i在不同的翻译单元中具有不同的值,如何解决这个问题?我不能使用类或其他任何东西,因为客户想要这种格式的代码。

笔记

我可以做如下的事情,但这不是主要问题,我想要一个全局变量:

t::i++; //instead of t::inc(); …
Run Code Online (Sandbox Code Playgroud)

c++ static inline c++17

2
推荐指数
1
解决办法
998
查看次数

与顺风动态内联更改类属性

如何使用带有 tailwind 内联 css 的字符串文字传递动态值?

例如,我想动态更改宽度,而不是使用预制的顺风 w-1、w-2 等...

<div
  class="p-1 border-2 width: {createTimeBlock(
    show.startTime,
    show.endTime,
  )}px">
  {show.startTime} to {show.endTime}
</div>
Run Code Online (Sandbox Code Playgroud)

javascript inline string-literals svelte tailwind-css

2
推荐指数
1
解决办法
1207
查看次数

Kotlin 作用域函数块是否有效内联?

我正在编写一个 Kotlin内联类,以使Decimal4J更方便,而无需实例化任何对象。我担心作用域函数可能会创建 lambda 对象,从而使整个事情变得毫无意义。

compareTo考虑以下示例中的函数。

/* imports and whatnot */

@JvmInline
value class Quantity(val basis: Long) {

    companion object {
        val scale: Int = 12
        val metrics: ScaleMetrics = Scales.getScaleMetrics(scale)
        val arithmetic: DecimalArithmetic = metrics.defaultArithmetic
    }

    operator fun compareTo(alt: Number): Int {
        with(arithmetic) {
            val normal = when (alt) {
                is Double     -> fromDouble(alt)
                is Float      -> fromFloat(alt)
                is Long       -> fromLong(alt)
                is BigDecimal -> fromBigDecimal(alt)
                is BigInteger -> fromBigInteger(alt)
                else          -> fromLong(alt.toLong())
            }
            return …
Run Code Online (Sandbox Code Playgroud)

primitive lambda inline kotlin

2
推荐指数
1
解决办法
495
查看次数

在 C++ 中使用内联说明符的正确方法是什么?

我的目标是减少我在class. 这些方法被其他方法使用,并且不打算公开访问。我做了一些研究,但无法整理我发现的信息。inline在定义中而不是在声明中指定方法是否足够?如果该方法可以公开访问,这是一种不好的技术吗?

文件.h

class Foo
{
    /* ... */
public:
    bool bar ( int par );
    void zar ( void );
    /* ... */
};
Run Code Online (Sandbox Code Playgroud)

文件.cpp

inline bool Foo::bar ( int par )
{
    /* ... */
}

void Foo::zar ( void )
{
    /* ... */

    if ( bar(10) )
    {
        /* ... */
    }

    /* ... */
}
Run Code Online (Sandbox Code Playgroud)

在这个例子中使用inline说明符是一个好的技术吗?

该代码可以运行,但我想了解不可预见的后果。这是否是正确的用法。

c++ methods inline class

2
推荐指数
1
解决办法
349
查看次数

我应该使用静态还是内联?

我写一个只有头库,我无法弥补,宣布我提供给用户的功能之间我的脑海里static或inline.在这种情况下,为什么我应该更喜欢一个到另一个?

c c++ static inline

1
推荐指数
1
解决办法
275
查看次数